Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c6f1f129f |
@@ -26,4 +26,4 @@ AUTH_PASSWORD_HASH=
|
||||
AUTH_ENABLED=false
|
||||
AUTH_SETUP_COMPLETED=false
|
||||
JWT_SECRET=
|
||||
DATABASE_URL="file:/opt/ProxmoxVE-Local/data/settings.db"
|
||||
DATABASE_URL="file:./data/database.sqlite"
|
||||
|
||||
29
.github/workflows/publish_release.yml
vendored
29
.github/workflows/publish_release.yml
vendored
@@ -46,6 +46,35 @@ jobs:
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git commit -m "chore: add VERSION $version" --allow-empty
|
||||
|
||||
|
||||
- name: Sync upstream JSONs
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
tmp_dir=$(mktemp -d)
|
||||
api_url="https://api.github.com/repos/community-scripts/ProxmoxVE/contents/frontend/public/json"
|
||||
# Fetch file list (no subfolders)
|
||||
curl -sSL -H "Authorization: token $GH_TOKEN" "$api_url" \
|
||||
| jq -r '.[] | select(.type=="file") | .name' > "$tmp_dir/files.txt"
|
||||
|
||||
# Download each file
|
||||
while IFS= read -r name; do
|
||||
curl -sSL -H "Authorization: token $GH_TOKEN" \
|
||||
"https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/frontend/public/json/$name" \
|
||||
-o "$tmp_dir/$name"
|
||||
done < "$tmp_dir/files.txt"
|
||||
|
||||
mkdir -p json
|
||||
rsync -a --delete "$tmp_dir/" json/
|
||||
|
||||
# Stage and amend commit to include JSON updates (and VERSION)
|
||||
git add json VERSION
|
||||
if ! git diff --cached --quiet; then
|
||||
git commit --amend --no-edit
|
||||
fi
|
||||
|
||||
|
||||
- name: Push changes
|
||||
run: |
|
||||
git push --force-with-lease --set-upstream origin "update-version-${{ steps.draft.outputs.tag_name }}"
|
||||
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -37,9 +37,6 @@ yarn-debug.log*
|
||||
yarn-error.log*
|
||||
.pnpm-debug.log*
|
||||
|
||||
update.log
|
||||
server.log
|
||||
|
||||
# local env files
|
||||
# do not commit any .env files to git, except for the .env.example file. https://create.t3.gg/en/usage/env-variables#using-environment-variables
|
||||
.env
|
||||
|
||||
44
json/frigate.json.bak
Normal file
44
json/frigate.json.bak
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "Frigate",
|
||||
"slug": "frigate",
|
||||
"categories": [
|
||||
15
|
||||
],
|
||||
"date_created": "2024-05-02",
|
||||
"type": "ct",
|
||||
"updateable": false,
|
||||
"privileged": true,
|
||||
"interface_port": 5000,
|
||||
"documentation": "https://docs.frigate.video/",
|
||||
"website": "https://frigate.video/",
|
||||
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/frigate.webp",
|
||||
"config_path": "",
|
||||
"description": "Frigate is an open source NVR built around real-time AI object detection. All processing is performed locally on your own hardware, and your camera feeds never leave your home.",
|
||||
"install_methods": [
|
||||
{
|
||||
"type": "default",
|
||||
"script": "ct/frigate.sh",
|
||||
"resources": {
|
||||
"cpu": 4,
|
||||
"ram": 4096,
|
||||
"hdd": 20,
|
||||
"os": "debian",
|
||||
"version": "11"
|
||||
}
|
||||
}
|
||||
],
|
||||
"default_credentials": {
|
||||
"username": null,
|
||||
"password": null
|
||||
},
|
||||
"notes": [
|
||||
{
|
||||
"text": "Discussions (explore more advanced methods): `https://github.com/tteck/Proxmox/discussions/2711`",
|
||||
"type": "info"
|
||||
},
|
||||
{
|
||||
"text": "go2rtc Interface port:`1984`",
|
||||
"type": "info"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
"documentation": "https://docs.openarchiver.com/",
|
||||
"config_path": "/opt/openarchiver/.env",
|
||||
"website": "https://openarchiver.com/",
|
||||
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/open-archiver.webp",
|
||||
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/OpenArchiver.webp",
|
||||
"description": "Open Archiver is a secure, self-hosted email archiving solution, and it's completely open source. Get an email archiver that enables full-text search across email and attachments. Create a permanent, searchable, and compliant mail archive from Google Workspace, Microsoft 35, and any IMAP server.",
|
||||
"install_methods": [
|
||||
{
|
||||
|
||||
396
package-lock.json
generated
396
package-lock.json
generated
@@ -22,16 +22,12 @@
|
||||
"@xterm/addon-fit": "^0.10.0",
|
||||
"@xterm/addon-web-links": "^0.11.0",
|
||||
"@xterm/xterm": "^5.5.0",
|
||||
"axios": "^1.7.9",
|
||||
"bcryptjs": "^3.0.2",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cron-validator": "^1.2.0",
|
||||
"dotenv": "^17.2.3",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"lucide-react": "^0.546.0",
|
||||
"next": "^15.5.6",
|
||||
"node-cron": "^3.0.3",
|
||||
"node-pty": "^1.0.0",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
@@ -41,7 +37,7 @@
|
||||
"remark-gfm": "^4.0.1",
|
||||
"server-only": "^0.0.1",
|
||||
"strip-ansi": "^7.1.2",
|
||||
"superjson": "^2.2.3",
|
||||
"superjson": "^2.2.1",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"ws": "^8.18.3",
|
||||
"zod": "^4.1.12"
|
||||
@@ -55,21 +51,20 @@
|
||||
"@types/bcryptjs": "^3.0.0",
|
||||
"@types/better-sqlite3": "^7.6.8",
|
||||
"@types/jsonwebtoken": "^9.0.10",
|
||||
"@types/node": "^24.9.1",
|
||||
"@types/node-cron": "^3.0.11",
|
||||
"@types/node": "^24.9.0",
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.2.2",
|
||||
"@vitejs/plugin-react": "^5.0.2",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"@vitest/ui": "^3.2.4",
|
||||
"eslint": "^9.38.0",
|
||||
"eslint-config-next": "^16.0.0",
|
||||
"eslint-config-next": "^15.5.6",
|
||||
"jsdom": "^27.0.1",
|
||||
"postcss": "^8.5.3",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-tailwindcss": "^0.7.1",
|
||||
"prisma": "^6.18.0",
|
||||
"tailwindcss": "^4.1.16",
|
||||
"prisma": "^6.17.1",
|
||||
"tailwindcss": "^4.1.15",
|
||||
"typescript": "^5.8.2",
|
||||
"typescript-eslint": "^8.46.2",
|
||||
"vitest": "^3.2.4"
|
||||
@@ -1838,9 +1833,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@next/eslint-plugin-next": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.0.0.tgz",
|
||||
"integrity": "sha512-IB7RzmmtrPOrpAgEBR1PIQPD0yea5lggh5cq54m51jHjjljU80Ia+czfxJYMlSDl1DPvpzb8S9TalCc0VMo9Hw==",
|
||||
"version": "15.5.6",
|
||||
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-15.5.6.tgz",
|
||||
"integrity": "sha512-YxDvsT2fwy1j5gMqk3ppXlsgDopHnkM4BoxSVASbvvgh5zgsK8lvWerDzPip8k3WVzsTZ1O7A7si1KNfN4OZfQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -2064,66 +2059,66 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@prisma/config": {
|
||||
"version": "6.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.18.0.tgz",
|
||||
"integrity": "sha512-rgFzspCpwsE+q3OF/xkp0fI2SJ3PfNe9LLMmuSVbAZ4nN66WfBiKqJKo/hLz3ysxiPQZf8h1SMf2ilqPMeWATQ==",
|
||||
"version": "6.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/config/-/config-6.17.1.tgz",
|
||||
"integrity": "sha512-fs8wY6DsvOCzuiyWVckrVs1LOcbY4LZNz8ki4uUIQ28jCCzojTGqdLhN2Jl5lDnC1yI8/gNIKpsWDM8pLhOdwA==",
|
||||
"devOptional": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"c12": "3.1.0",
|
||||
"deepmerge-ts": "7.1.5",
|
||||
"effect": "3.18.4",
|
||||
"effect": "3.16.12",
|
||||
"empathic": "2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@prisma/debug": {
|
||||
"version": "6.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.18.0.tgz",
|
||||
"integrity": "sha512-PMVPMmxPj0ps1VY75DIrT430MoOyQx9hmm174k6cmLZpcI95rAPXOQ+pp8ANQkJtNyLVDxnxVJ0QLbrm/ViBcg==",
|
||||
"version": "6.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-6.17.1.tgz",
|
||||
"integrity": "sha512-Vf7Tt5Wh9XcndpbmeotuqOMLWPTjEKCsgojxXP2oxE1/xYe7PtnP76hsouG9vis6fctX+TxgmwxTuYi/+xc7dQ==",
|
||||
"devOptional": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@prisma/engines": {
|
||||
"version": "6.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.18.0.tgz",
|
||||
"integrity": "sha512-i5RzjGF/ex6AFgqEe2o1IW8iIxJGYVQJVRau13kHPYEL1Ck8Zvwuzamqed/1iIljs5C7L+Opiz5TzSsUebkriA==",
|
||||
"version": "6.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-6.17.1.tgz",
|
||||
"integrity": "sha512-D95Ik3GYZkqZ8lSR4EyFOJ/tR33FcYRP8kK61o+WMsyD10UfJwd7+YielflHfKwiGodcqKqoraWw8ElAgMDbPw==",
|
||||
"devOptional": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@prisma/debug": "6.18.0",
|
||||
"@prisma/engines-version": "6.18.0-8.34b5a692b7bd79939a9a2c3ef97d816e749cda2f",
|
||||
"@prisma/fetch-engine": "6.18.0",
|
||||
"@prisma/get-platform": "6.18.0"
|
||||
"@prisma/debug": "6.17.1",
|
||||
"@prisma/engines-version": "6.17.1-1.272a37d34178c2894197e17273bf937f25acdeac",
|
||||
"@prisma/fetch-engine": "6.17.1",
|
||||
"@prisma/get-platform": "6.17.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@prisma/engines-version": {
|
||||
"version": "6.18.0-8.34b5a692b7bd79939a9a2c3ef97d816e749cda2f",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.18.0-8.34b5a692b7bd79939a9a2c3ef97d816e749cda2f.tgz",
|
||||
"integrity": "sha512-T7Af4QsJQnSgWN1zBbX+Cha5t4qjHRxoeoWpK4JugJzG/ipmmDMY5S+O0N1ET6sCBNVkf6lz+Y+ZNO9+wFU8pQ==",
|
||||
"version": "6.17.1-1.272a37d34178c2894197e17273bf937f25acdeac",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-6.17.1-1.272a37d34178c2894197e17273bf937f25acdeac.tgz",
|
||||
"integrity": "sha512-17140E3huOuD9lMdJ9+SF/juOf3WR3sTJMVyyenzqUPbuH+89nPhSWcrY+Mf7tmSs6HvaO+7S+HkELinn6bhdg==",
|
||||
"devOptional": true,
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/@prisma/fetch-engine": {
|
||||
"version": "6.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.18.0.tgz",
|
||||
"integrity": "sha512-TdaBvTtBwP3IoqVYoGIYpD4mWlk0pJpjTJjir/xLeNWlwog7Sl3bD2J0jJ8+5+q/6RBg+acb9drsv5W6lqae7A==",
|
||||
"version": "6.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-6.17.1.tgz",
|
||||
"integrity": "sha512-AYZiHOs184qkDMiTeshyJCtyL4yERkjfTkJiSJdYuSfc24m94lTNL5+GFinZ6vVz+ktX4NJzHKn1zIFzGTWrWg==",
|
||||
"devOptional": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@prisma/debug": "6.18.0",
|
||||
"@prisma/engines-version": "6.18.0-8.34b5a692b7bd79939a9a2c3ef97d816e749cda2f",
|
||||
"@prisma/get-platform": "6.18.0"
|
||||
"@prisma/debug": "6.17.1",
|
||||
"@prisma/engines-version": "6.17.1-1.272a37d34178c2894197e17273bf937f25acdeac",
|
||||
"@prisma/get-platform": "6.17.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@prisma/get-platform": {
|
||||
"version": "6.18.0",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.18.0.tgz",
|
||||
"integrity": "sha512-uXNJCJGhxTCXo2B25Ta91Rk1/Nmlqg9p7G9GKh8TPhxvAyXCvMNQoogj4JLEUy+3ku8g59cpyQIKFhqY2xO2bg==",
|
||||
"version": "6.17.1",
|
||||
"resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-6.17.1.tgz",
|
||||
"integrity": "sha512-AKEn6fsfz0r482S5KRDFlIGEaq9wLNcgalD1adL+fPcFFblIKs1sD81kY/utrHdqKuVC6E1XSRpegDK3ZLL4Qg==",
|
||||
"devOptional": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@prisma/debug": "6.18.0"
|
||||
"@prisma/debug": "6.17.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/primitive": {
|
||||
@@ -2981,6 +2976,13 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@rushstack/eslint-patch": {
|
||||
"version": "1.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.13.0.tgz",
|
||||
"integrity": "sha512-2ih5qGw5SZJ+2fLZxP6Lr6Na2NTIgPRL/7Kmyuw0uIyBQnuhQ8fi8fzUTd38eIQmqp+GYLC00cI6WgtqHxBwmw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@standard-schema/spec": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.0.0.tgz",
|
||||
@@ -3068,13 +3070,6 @@
|
||||
"tailwindcss": "4.1.15"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/node/node_modules/tailwindcss": {
|
||||
"version": "4.1.15",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.15.tgz",
|
||||
"integrity": "sha512-k2WLnWkYFkdpRv+Oby3EBXIyQC8/s1HOFMBUViwtAh6Z5uAozeUSMQlIsn/c6Q2iJzqG6aJT3wdPaRNj70iYxQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tailwindcss/oxide": {
|
||||
"version": "4.1.15",
|
||||
"resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.1.15.tgz",
|
||||
@@ -3390,13 +3385,6 @@
|
||||
"tailwindcss": "4.1.15"
|
||||
}
|
||||
},
|
||||
"node_modules/@tailwindcss/postcss/node_modules/tailwindcss": {
|
||||
"version": "4.1.15",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.15.tgz",
|
||||
"integrity": "sha512-k2WLnWkYFkdpRv+Oby3EBXIyQC8/s1HOFMBUViwtAh6Z5uAozeUSMQlIsn/c6Q2iJzqG6aJT3wdPaRNj70iYxQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tailwindcss/typography": {
|
||||
"version": "0.5.19",
|
||||
"resolved": "https://registry.npmjs.org/@tailwindcss/typography/-/typography-0.5.19.tgz",
|
||||
@@ -3743,21 +3731,14 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "24.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz",
|
||||
"integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==",
|
||||
"version": "24.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.0.tgz",
|
||||
"integrity": "sha512-MKNwXh3seSK8WurXF7erHPJ2AONmMwkI7zAMrXZDPIru8jRqkk6rGDBVbw4mLwfqA+ZZliiDPg05JQ3uW66tKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~7.16.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node-cron": {
|
||||
"version": "3.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-cron/-/node-cron-3.0.11.tgz",
|
||||
"integrity": "sha512-0ikrnug3/IyneSHqCBeslAhlK2aBfYek1fGo4bP4QnZPmiqSGRK+Oy7ZMisLWkesffJvQ1cqAcBnJC+8+nxIAg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/prismjs": {
|
||||
"version": "1.26.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.5.tgz",
|
||||
@@ -4910,12 +4891,6 @@
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/available-typed-arrays": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
|
||||
@@ -4942,17 +4917,6 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/axios": {
|
||||
"version": "1.12.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-1.12.2.tgz",
|
||||
"integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"follow-redirects": "^1.15.6",
|
||||
"form-data": "^4.0.4",
|
||||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/axobject-query": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",
|
||||
@@ -5102,19 +5066,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/c12/node_modules/dotenv": {
|
||||
"version": "16.6.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz",
|
||||
"integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
|
||||
"devOptional": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://dotenvx.com"
|
||||
}
|
||||
},
|
||||
"node_modules/cac": {
|
||||
"version": "6.7.14",
|
||||
"resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz",
|
||||
@@ -5148,6 +5099,7 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
@@ -5371,18 +5323,6 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/comma-separated-tokens": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",
|
||||
@@ -5425,26 +5365,20 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/copy-anything": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-4.0.5.tgz",
|
||||
"integrity": "sha512-7Vv6asjS4gMOuILabD3l739tsaxFQmC+a7pLZm02zyvs8p977bL3zEgq3yDk5rn9B0PbYgIv++jmHcuUab4RhA==",
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-3.0.5.tgz",
|
||||
"integrity": "sha512-yCEafptTtb4bk7GLEQoM8KVJpxAfdBJYaXyzQEgQQQgYrZiDp8SJmGKlYza6CYjEDNstAdNdKA3UuoULlEbS6w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-what": "^5.2.0"
|
||||
"is-what": "^4.1.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=12.13"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/mesqueeb"
|
||||
}
|
||||
},
|
||||
"node_modules/cron-validator": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/cron-validator/-/cron-validator-1.4.0.tgz",
|
||||
"integrity": "sha512-wGcJ9FCy65iaU6egSH8b5dZYJF7GU/3Jh06wzaT9lsa5dbqExjljmu+0cJ8cpKn+vUyZa/EM4WAxeLR6SypJXw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||
@@ -5696,15 +5630,6 @@
|
||||
"devOptional": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/dequal": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",
|
||||
@@ -5772,9 +5697,10 @@
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "17.2.3",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.3.tgz",
|
||||
"integrity": "sha512-JVUnt+DUIzu87TABbhPmNfVdBDt18BLOWjMUFJMSi/Qqg7NTYtabbvSNJGOJ7afbRuv9D/lngizHtP7QyLQ+9w==",
|
||||
"version": "16.6.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz",
|
||||
"integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
|
||||
"devOptional": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
@@ -5787,6 +5713,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
@@ -5814,9 +5741,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/effect": {
|
||||
"version": "3.18.4",
|
||||
"resolved": "https://registry.npmjs.org/effect/-/effect-3.18.4.tgz",
|
||||
"integrity": "sha512-b1LXQJLe9D11wfnOKAk3PKxuqYshQ0Heez+y5pnkd3jLj1yx9QhM72zZ9uUrOQyNvrs2GZZd/3maL0ZV18YuDA==",
|
||||
"version": "3.16.12",
|
||||
"resolved": "https://registry.npmjs.org/effect/-/effect-3.16.12.tgz",
|
||||
"integrity": "sha512-N39iBk0K71F9nb442TLbTkjl24FLUzuvx2i1I2RsEAQsdAdUTuUoW0vlfUXgkMTUOnYqKnWcFfqw4hK4Pw27hg==",
|
||||
"devOptional": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -5948,6 +5875,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -5957,6 +5885,7 @@
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -6001,6 +5930,7 @@
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
@@ -6013,6 +5943,7 @@
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
|
||||
"integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
@@ -6181,24 +6112,25 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-config-next": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.0.0.tgz",
|
||||
"integrity": "sha512-DWKT1YAO9ex2rK0/EeiPpKU++ghTiG59z6m08/ReLRECOYIaEv17maSCYT8zmFQLwIrY5lhJ+iaJPQdT4sJd4g==",
|
||||
"version": "15.5.6",
|
||||
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-15.5.6.tgz",
|
||||
"integrity": "sha512-cGr3VQlPsZBEv8rtYp4BpG1KNXDqGvPo9VC1iaCgIA11OfziC/vczng+TnAS3WpRIR3Q5ye/6yl+CRUuZ1fPGg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@next/eslint-plugin-next": "16.0.0",
|
||||
"@next/eslint-plugin-next": "15.5.6",
|
||||
"@rushstack/eslint-patch": "^1.10.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
|
||||
"@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || ^7.0.0 || ^8.0.0",
|
||||
"eslint-import-resolver-node": "^0.3.6",
|
||||
"eslint-import-resolver-typescript": "^3.5.2",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.0",
|
||||
"eslint-plugin-react": "^7.37.0",
|
||||
"eslint-plugin-react-hooks": "^7.0.0",
|
||||
"globals": "16.4.0",
|
||||
"typescript-eslint": "^8.46.0"
|
||||
"eslint-plugin-react-hooks": "^5.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": ">=9.0.0",
|
||||
"eslint": "^7.23.0 || ^8.0.0 || ^9.0.0",
|
||||
"typescript": ">=3.3.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
@@ -6207,19 +6139,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-config-next/node_modules/globals": {
|
||||
"version": "16.4.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-16.4.0.tgz",
|
||||
"integrity": "sha512-ob/2LcVVaVGCYN+r14cnwnoDPUufjiYgSqRhiFD0Q1iI4Odora5RE8Iv1D24hAz5oMophRGkGz+yuvQmmUMnMw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-import-resolver-node": {
|
||||
"version": "0.3.9",
|
||||
"resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz",
|
||||
@@ -6423,20 +6342,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-react-hooks": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-7.0.0.tgz",
|
||||
"integrity": "sha512-fNXaOwvKwq2+pXiRpXc825Vd63+KM4DLL40Rtlycb8m7fYpp6efrTp1sa6ZbP/Ap58K2bEKFXRmhURE+CJAQWw==",
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-5.2.0.tgz",
|
||||
"integrity": "sha512-+f15FfK64YQwZdJNELETdn5ibXEUQmW1DZL6KXhNnc2heoy/sg9VJJeT7n8TlMWouzWqSWavFkIhHyIbIAEapg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.24.4",
|
||||
"@babel/parser": "^7.24.4",
|
||||
"hermes-parser": "^0.25.1",
|
||||
"zod": "^3.22.4 || ^4.0.0",
|
||||
"zod-validation-error": "^3.0.3 || ^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=10"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0"
|
||||
@@ -6765,26 +6677,6 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/follow-redirects": {
|
||||
"version": "1.15.11",
|
||||
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz",
|
||||
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "individual",
|
||||
"url": "https://github.com/sponsors/RubenVerborgh"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"debug": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/for-each": {
|
||||
"version": "0.3.5",
|
||||
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz",
|
||||
@@ -6818,22 +6710,6 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz",
|
||||
"integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"es-set-tostringtag": "^2.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/format": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz",
|
||||
@@ -6861,6 +6737,7 @@
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
@@ -6921,6 +6798,7 @@
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
@@ -6954,6 +6832,7 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
@@ -7106,6 +6985,7 @@
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -7184,6 +7064,7 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -7196,6 +7077,7 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
|
||||
"integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"has-symbols": "^1.0.3"
|
||||
@@ -7211,6 +7093,7 @@
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
@@ -7289,23 +7172,6 @@
|
||||
"url": "https://opencollective.com/unified"
|
||||
}
|
||||
},
|
||||
"node_modules/hermes-estree": {
|
||||
"version": "0.25.1",
|
||||
"resolved": "https://registry.npmjs.org/hermes-estree/-/hermes-estree-0.25.1.tgz",
|
||||
"integrity": "sha512-0wUoCcLp+5Ev5pDW2OriHC2MJCbwLwuRx+gAqMTOkGKJJiBCLjtrvy4PWUGn6MIVefecRpzoOZ/UV6iGdOr+Cw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/hermes-parser": {
|
||||
"version": "0.25.1",
|
||||
"resolved": "https://registry.npmjs.org/hermes-parser/-/hermes-parser-0.25.1.tgz",
|
||||
"integrity": "sha512-6pEjquH3rqaI6cYAXYPcz9MS4rY6R4ngRgrgfDshRptUZIc3lw0MCIJIGDj9++mfySOuPTHB4nrSW99BCvOPIA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"hermes-estree": "0.25.1"
|
||||
}
|
||||
},
|
||||
"node_modules/highlight.js": {
|
||||
"version": "10.7.3",
|
||||
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz",
|
||||
@@ -7949,12 +7815,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/is-what": {
|
||||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/is-what/-/is-what-5.5.0.tgz",
|
||||
"integrity": "sha512-oG7cgbmg5kLYae2N5IVd3jm2s+vldjxJzK1pcu9LfpGuQ93MQSzo0okvRna+7y5ifrD+20FE8FvjusyGaz14fw==",
|
||||
"version": "4.1.16",
|
||||
"resolved": "https://registry.npmjs.org/is-what/-/is-what-4.1.16.tgz",
|
||||
"integrity": "sha512-ZhMwEosbFJkA0YhFnNDgTM4ZxDRsS6HqTo7qsZM08fehyRYIYa0yHu5R6mgo1n/8MgaPBXiPimPD77baVFYg+A==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=12.13"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/mesqueeb"
|
||||
@@ -8759,6 +8625,7 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -9640,27 +9507,6 @@
|
||||
"node": ">=8.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/min-indent": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz",
|
||||
@@ -9847,18 +9693,6 @@
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/node-cron": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.3.tgz",
|
||||
"integrity": "sha512-dOal67//nohNgYWb+nWmg5dkFdIwDm8EpeGYMekPMrngV3637lqnX0lbUcCtgibHTz6SEz7DAIjKvKDFYCnO1A==",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch-native": {
|
||||
"version": "1.6.7",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.7.tgz",
|
||||
@@ -10460,15 +10294,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/prisma": {
|
||||
"version": "6.18.0",
|
||||
"resolved": "https://registry.npmjs.org/prisma/-/prisma-6.18.0.tgz",
|
||||
"integrity": "sha512-bXWy3vTk8mnRmT+SLyZBQoC2vtV9Z8u7OHvEu+aULYxwiop/CPiFZ+F56KsNRNf35jw+8wcu8pmLsjxpBxAO9g==",
|
||||
"version": "6.17.1",
|
||||
"resolved": "https://registry.npmjs.org/prisma/-/prisma-6.17.1.tgz",
|
||||
"integrity": "sha512-ac6h0sM1Tg3zu8NInY+qhP/S9KhENVaw9n1BrGKQVFu05JT5yT5Qqqmb8tMRIE3ZXvVj4xcRA5yfrsy4X7Yy5g==",
|
||||
"devOptional": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@prisma/config": "6.18.0",
|
||||
"@prisma/engines": "6.18.0"
|
||||
"@prisma/config": "6.17.1",
|
||||
"@prisma/engines": "6.17.1"
|
||||
},
|
||||
"bin": {
|
||||
"prisma": "build/index.js"
|
||||
@@ -10523,12 +10357,6 @@
|
||||
"url": "https://github.com/sponsors/wooorm"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/punycode": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
|
||||
@@ -11941,12 +11769,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/superjson": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/superjson/-/superjson-2.2.3.tgz",
|
||||
"integrity": "sha512-ay3d+LW/S6yppKoTz3Bq4mG0xrS5bFwfWEBmQfbC7lt5wmtk+Obq0TxVuA9eYRirBTQb1K3eEpBRHMQEo0WyVw==",
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/superjson/-/superjson-2.2.2.tgz",
|
||||
"integrity": "sha512-5JRxVqC8I8NuOUjzBbvVJAKNM8qoVuH0O77h4WInc/qC2q5IreqKxYwgkga3PfA22OayK2ikceb/B26dztPl+Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"copy-anything": "^4"
|
||||
"copy-anything": "^3.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
@@ -11996,9 +11824,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/tailwindcss": {
|
||||
"version": "4.1.16",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.16.tgz",
|
||||
"integrity": "sha512-pONL5awpaQX4LN5eiv7moSiSPd/DLDzKVRJz8Q9PgzmAdd1R4307GQS2ZpfiN7ZmekdQrfhZZiSE5jkLR4WNaA==",
|
||||
"version": "4.1.15",
|
||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.15.tgz",
|
||||
"integrity": "sha512-k2WLnWkYFkdpRv+Oby3EBXIyQC8/s1HOFMBUViwtAh6Z5uAozeUSMQlIsn/c6Q2iJzqG6aJT3wdPaRNj70iYxQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tapable": {
|
||||
@@ -12647,15 +12475,6 @@
|
||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/vfile": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/vfile/-/vfile-6.0.3.tgz",
|
||||
@@ -13252,19 +13071,6 @@
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
},
|
||||
"node_modules/zod-validation-error": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/zod-validation-error/-/zod-validation-error-4.0.2.tgz",
|
||||
"integrity": "sha512-Q6/nZLe6jxuU80qb/4uJ4t5v2VEZ44lzQjPDhYJNztRQ4wyWc6VF3D3Kb/fAuPetZQnhS3hnajCf9CsWesghLQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "^3.25.0 || ^4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/zwitch": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",
|
||||
|
||||
15
package.json
15
package.json
@@ -36,16 +36,12 @@
|
||||
"@xterm/addon-fit": "^0.10.0",
|
||||
"@xterm/addon-web-links": "^0.11.0",
|
||||
"@xterm/xterm": "^5.5.0",
|
||||
"axios": "^1.7.9",
|
||||
"bcryptjs": "^3.0.2",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cron-validator": "^1.2.0",
|
||||
"dotenv": "^17.2.3",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"lucide-react": "^0.546.0",
|
||||
"next": "^15.5.6",
|
||||
"node-cron": "^3.0.3",
|
||||
"node-pty": "^1.0.0",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
@@ -55,7 +51,7 @@
|
||||
"remark-gfm": "^4.0.1",
|
||||
"server-only": "^0.0.1",
|
||||
"strip-ansi": "^7.1.2",
|
||||
"superjson": "^2.2.3",
|
||||
"superjson": "^2.2.1",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"ws": "^8.18.3",
|
||||
"zod": "^4.1.12"
|
||||
@@ -69,21 +65,20 @@
|
||||
"@types/bcryptjs": "^3.0.0",
|
||||
"@types/better-sqlite3": "^7.6.8",
|
||||
"@types/jsonwebtoken": "^9.0.10",
|
||||
"@types/node": "^24.9.1",
|
||||
"@types/node-cron": "^3.0.11",
|
||||
"@types/node": "^24.9.0",
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.2.2",
|
||||
"@vitejs/plugin-react": "^5.0.2",
|
||||
"@vitest/coverage-v8": "^3.2.4",
|
||||
"@vitest/ui": "^3.2.4",
|
||||
"eslint": "^9.38.0",
|
||||
"eslint-config-next": "^16.0.0",
|
||||
"eslint-config-next": "^15.5.6",
|
||||
"jsdom": "^27.0.1",
|
||||
"postcss": "^8.5.3",
|
||||
"prettier": "^3.5.3",
|
||||
"prettier-plugin-tailwindcss": "^0.7.1",
|
||||
"prisma": "^6.18.0",
|
||||
"tailwindcss": "^4.1.16",
|
||||
"prisma": "^6.17.1",
|
||||
"tailwindcss": "^4.1.15",
|
||||
"typescript": "^5.8.2",
|
||||
"typescript-eslint": "^8.46.2",
|
||||
"vitest": "^3.2.4"
|
||||
|
||||
@@ -439,14 +439,17 @@ advanced_settings() {
|
||||
exit_script
|
||||
fi
|
||||
done
|
||||
|
||||
if CT_ID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Container ID" 8 58 "$NEXTID" --title "CONTAINER ID" 3>&1 1>&2 2>&3); then
|
||||
if [ -z "$CT_ID" ]; then
|
||||
CT_ID="$NEXTID"
|
||||
echo -e "${CONTAINERID}${BOLD}${DGN}Container ID: ${BGN}$CT_ID${CL}"
|
||||
else
|
||||
echo -e "${CONTAINERID}${BOLD}${DGN}Container ID: ${BGN}$CT_ID${CL}"
|
||||
fi
|
||||
else
|
||||
exit_script
|
||||
fi
|
||||
echo -e "${CONTAINERID}${BOLD}${DGN}Container ID: ${BGN}$CT_ID${CL}"
|
||||
|
||||
while true; do
|
||||
if CT_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 "$NSAPP" --title "HOSTNAME" 3>&1 1>&2 2>&3); then
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
11
server.js
11
server.js
@@ -8,11 +8,6 @@ import stripAnsi from 'strip-ansi';
|
||||
import { spawn as ptySpawn } from 'node-pty';
|
||||
import { getSSHExecutionService } from './src/server/ssh-execution-service.js';
|
||||
import { getDatabase } from './src/server/database-prisma.js';
|
||||
import { initializeAutoSync, setupGracefulShutdown } from './src/server/lib/autoSyncInit.js';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
// Load environment variables from .env file
|
||||
dotenv.config();
|
||||
// Fallback minimal global error handlers for Node runtime (avoid TS import)
|
||||
function registerGlobalErrorHandlers() {
|
||||
if (registerGlobalErrorHandlers._registered) return;
|
||||
@@ -981,11 +976,5 @@ app.prepare().then(() => {
|
||||
.listen(port, hostname, () => {
|
||||
console.log(`> Ready on http://${hostname}:${port}`);
|
||||
console.log(`> WebSocket server running on ws://${hostname}:${port}/ws/script-execution`);
|
||||
|
||||
// Initialize auto-sync service
|
||||
initializeAutoSync();
|
||||
|
||||
// Setup graceful shutdown handlers
|
||||
setupGracefulShutdown();
|
||||
});
|
||||
});
|
||||
|
||||
6
server.log
Normal file
6
server.log
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
> pve-scripts-local@0.1.0 start
|
||||
> node server.js
|
||||
|
||||
> Ready on http://0.0.0.0:3000
|
||||
> WebSocket server running on ws://0.0.0.0:3000/ws/script-execution
|
||||
@@ -7,7 +7,6 @@ import { Toggle } from './ui/toggle';
|
||||
import { ContextualHelpIcon } from './ContextualHelpIcon';
|
||||
import { useTheme } from './ThemeProvider';
|
||||
import { useRegisterModal } from './modal/ModalStackProvider';
|
||||
import { api } from '~/trpc/react';
|
||||
|
||||
interface GeneralSettingsModalProps {
|
||||
isOpen: boolean;
|
||||
@@ -17,7 +16,7 @@ interface GeneralSettingsModalProps {
|
||||
export function GeneralSettingsModal({ isOpen, onClose }: GeneralSettingsModalProps) {
|
||||
useRegisterModal(isOpen, { id: 'general-settings-modal', allowEscape: true, onClose });
|
||||
const { theme, setTheme } = useTheme();
|
||||
const [activeTab, setActiveTab] = useState<'general' | 'github' | 'auth' | 'auto-sync'>('general');
|
||||
const [activeTab, setActiveTab] = useState<'general' | 'github' | 'auth'>('general');
|
||||
const [githubToken, setGithubToken] = useState('');
|
||||
const [saveFilter, setSaveFilter] = useState(false);
|
||||
const [savedFilters, setSavedFilters] = useState<any>(null);
|
||||
@@ -35,19 +34,6 @@ export function GeneralSettingsModal({ isOpen, onClose }: GeneralSettingsModalPr
|
||||
const [authSetupCompleted, setAuthSetupCompleted] = useState(false);
|
||||
const [authLoading, setAuthLoading] = useState(false);
|
||||
|
||||
// Auto-sync state
|
||||
const [autoSyncEnabled, setAutoSyncEnabled] = useState(false);
|
||||
const [syncIntervalType, setSyncIntervalType] = useState<'predefined' | 'custom'>('predefined');
|
||||
const [syncIntervalPredefined, setSyncIntervalPredefined] = useState('1hour');
|
||||
const [syncIntervalCron, setSyncIntervalCron] = useState('');
|
||||
const [autoDownloadNew, setAutoDownloadNew] = useState(false);
|
||||
const [autoUpdateExisting, setAutoUpdateExisting] = useState(false);
|
||||
const [notificationEnabled, setNotificationEnabled] = useState(false);
|
||||
const [appriseUrls, setAppriseUrls] = useState<string[]>([]);
|
||||
const [appriseUrlsText, setAppriseUrlsText] = useState('');
|
||||
const [lastAutoSync, setLastAutoSync] = useState('');
|
||||
const [cronValidationError, setCronValidationError] = useState('');
|
||||
|
||||
// Load existing settings when modal opens
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
@@ -56,7 +42,6 @@ export function GeneralSettingsModal({ isOpen, onClose }: GeneralSettingsModalPr
|
||||
void loadSavedFilters();
|
||||
void loadAuthCredentials();
|
||||
void loadColorCodingSetting();
|
||||
void loadAutoSyncSettings();
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
@@ -293,162 +278,6 @@ export function GeneralSettingsModal({ isOpen, onClose }: GeneralSettingsModalPr
|
||||
}
|
||||
};
|
||||
|
||||
// Auto-sync functions
|
||||
const loadAutoSyncSettings = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/settings/auto-sync');
|
||||
if (response.ok) {
|
||||
const data = await response.json() as { settings: any };
|
||||
const settings = data.settings;
|
||||
if (settings) {
|
||||
setAutoSyncEnabled(settings.autoSyncEnabled ?? false);
|
||||
setSyncIntervalType(settings.syncIntervalType ?? 'predefined');
|
||||
setSyncIntervalPredefined(settings.syncIntervalPredefined ?? '1hour');
|
||||
setSyncIntervalCron(settings.syncIntervalCron ?? '');
|
||||
setAutoDownloadNew(settings.autoDownloadNew ?? false);
|
||||
setAutoUpdateExisting(settings.autoUpdateExisting ?? false);
|
||||
setNotificationEnabled(settings.notificationEnabled ?? false);
|
||||
setAppriseUrls(settings.appriseUrls ?? []);
|
||||
setAppriseUrlsText((settings.appriseUrls ?? []).join('\n'));
|
||||
setLastAutoSync(settings.lastAutoSync ?? '');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error loading auto-sync settings:', error);
|
||||
}
|
||||
};
|
||||
|
||||
const saveAutoSyncSettings = async () => {
|
||||
setIsSaving(true);
|
||||
setMessage(null);
|
||||
|
||||
try {
|
||||
// Validate cron expression if custom
|
||||
if (syncIntervalType === 'custom' && syncIntervalCron) {
|
||||
const response = await fetch('/api/settings/auto-sync', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
autoSyncEnabled,
|
||||
syncIntervalType,
|
||||
syncIntervalPredefined,
|
||||
syncIntervalCron,
|
||||
autoDownloadNew,
|
||||
autoUpdateExisting,
|
||||
notificationEnabled,
|
||||
appriseUrls: appriseUrls
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json();
|
||||
setMessage({ type: 'error', text: errorData.error ?? 'Failed to save auto-sync settings' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const response = await fetch('/api/settings/auto-sync', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
autoSyncEnabled,
|
||||
syncIntervalType,
|
||||
syncIntervalPredefined,
|
||||
syncIntervalCron,
|
||||
autoDownloadNew,
|
||||
autoUpdateExisting,
|
||||
notificationEnabled,
|
||||
appriseUrls: appriseUrls
|
||||
})
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
setMessage({ type: 'success', text: 'Auto-sync settings saved successfully!' });
|
||||
setTimeout(() => setMessage(null), 3000);
|
||||
} else {
|
||||
const errorData = await response.json();
|
||||
setMessage({ type: 'error', text: errorData.error ?? 'Failed to save auto-sync settings' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving auto-sync settings:', error);
|
||||
setMessage({ type: 'error', text: 'Failed to save auto-sync settings' });
|
||||
} finally {
|
||||
setIsSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAppriseUrlsChange = (text: string) => {
|
||||
setAppriseUrlsText(text);
|
||||
const urls = text.split('\n').filter(url => url.trim() !== '');
|
||||
setAppriseUrls(urls);
|
||||
};
|
||||
|
||||
const validateCronExpression = (cron: string) => {
|
||||
if (!cron.trim()) {
|
||||
setCronValidationError('');
|
||||
return true;
|
||||
}
|
||||
|
||||
// Basic cron validation - you might want to use a library like cron-validator
|
||||
const cronRegex = /^(\*|([0-5]?\d)) (\*|([01]?\d|2[0-3])) (\*|([012]?\d|3[01])) (\*|([0]?\d|1[0-2])) (\*|([0-6]))$/;
|
||||
const isValid = cronRegex.test(cron);
|
||||
|
||||
if (!isValid) {
|
||||
setCronValidationError('Invalid cron expression format');
|
||||
return false;
|
||||
}
|
||||
|
||||
setCronValidationError('');
|
||||
return true;
|
||||
};
|
||||
|
||||
const handleCronChange = (cron: string) => {
|
||||
setSyncIntervalCron(cron);
|
||||
validateCronExpression(cron);
|
||||
};
|
||||
|
||||
const testNotification = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/settings/auto-sync', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ testNotification: true })
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
setMessage({ type: 'success', text: 'Test notification sent successfully!' });
|
||||
} else {
|
||||
const errorData = await response.json();
|
||||
setMessage({ type: 'error', text: errorData.error ?? 'Failed to send test notification' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error sending test notification:', error);
|
||||
setMessage({ type: 'error', text: 'Failed to send test notification' });
|
||||
}
|
||||
};
|
||||
|
||||
const triggerManualSync = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/settings/auto-sync', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ triggerManualSync: true })
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
setMessage({ type: 'success', text: 'Manual sync triggered successfully!' });
|
||||
// Reload settings to get updated last sync time
|
||||
await loadAutoSyncSettings();
|
||||
} else {
|
||||
const errorData = await response.json();
|
||||
setMessage({ type: 'error', text: errorData.error ?? 'Failed to trigger manual sync' });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error triggering manual sync:', error);
|
||||
setMessage({ type: 'error', text: 'Failed to trigger manual sync' });
|
||||
}
|
||||
};
|
||||
|
||||
if (!isOpen) return null;
|
||||
|
||||
return (
|
||||
@@ -511,18 +340,6 @@ export function GeneralSettingsModal({ isOpen, onClose }: GeneralSettingsModalPr
|
||||
>
|
||||
Authentication
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => setActiveTab('auto-sync')}
|
||||
variant="ghost"
|
||||
size="null"
|
||||
className={`py-3 sm:py-4 px-1 border-b-2 font-medium text-sm w-full sm:w-auto ${
|
||||
activeTab === 'auto-sync'
|
||||
? 'border-primary text-primary'
|
||||
: 'border-transparent text-muted-foreground hover:text-foreground hover:border-border'
|
||||
}`}
|
||||
>
|
||||
Auto-Sync
|
||||
</Button>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
@@ -806,249 +623,6 @@ export function GeneralSettingsModal({ isOpen, onClose }: GeneralSettingsModalPr
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{activeTab === 'auto-sync' && (
|
||||
<div className="space-y-4 sm:space-y-6">
|
||||
<div>
|
||||
<h3 className="text-base sm:text-lg font-medium text-foreground mb-3 sm:mb-4">Auto-Sync Settings</h3>
|
||||
<p className="text-sm sm:text-base text-muted-foreground mb-4">
|
||||
Configure automatic synchronization of scripts with configurable intervals and notifications.
|
||||
</p>
|
||||
|
||||
{/* Enable Auto-Sync */}
|
||||
<div className="p-4 border border-border rounded-lg mb-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h4 className="font-medium text-foreground mb-1">Enable Auto-Sync</h4>
|
||||
<p className="text-sm text-muted-foreground">Automatically sync JSON files from GitHub at specified intervals</p>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={autoSyncEnabled}
|
||||
onCheckedChange={setAutoSyncEnabled}
|
||||
disabled={isSaving}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Sync Interval */}
|
||||
{autoSyncEnabled && (
|
||||
<div className="p-4 border border-border rounded-lg mb-4">
|
||||
<h4 className="font-medium text-foreground mb-3">Sync Interval</h4>
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="flex space-x-4">
|
||||
<label className="flex items-center">
|
||||
<input
|
||||
type="radio"
|
||||
name="syncIntervalType"
|
||||
value="predefined"
|
||||
checked={syncIntervalType === 'predefined'}
|
||||
onChange={(e) => setSyncIntervalType(e.target.value as 'predefined' | 'custom')}
|
||||
className="mr-2"
|
||||
/>
|
||||
Predefined
|
||||
</label>
|
||||
<label className="flex items-center">
|
||||
<input
|
||||
type="radio"
|
||||
name="syncIntervalType"
|
||||
value="custom"
|
||||
checked={syncIntervalType === 'custom'}
|
||||
onChange={(e) => setSyncIntervalType(e.target.value as 'predefined' | 'custom')}
|
||||
className="mr-2"
|
||||
/>
|
||||
Custom Cron
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{syncIntervalType === 'predefined' && (
|
||||
<div>
|
||||
<select
|
||||
value={syncIntervalPredefined}
|
||||
onChange={(e) => setSyncIntervalPredefined(e.target.value)}
|
||||
className="w-full p-2 border border-border rounded-md bg-background"
|
||||
>
|
||||
<option value="15min">Every 15 minutes</option>
|
||||
<option value="30min">Every 30 minutes</option>
|
||||
<option value="1hour">Every hour</option>
|
||||
<option value="6hours">Every 6 hours</option>
|
||||
<option value="12hours">Every 12 hours</option>
|
||||
<option value="24hours">Every 24 hours</option>
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{syncIntervalType === 'custom' && (
|
||||
<div>
|
||||
<Input
|
||||
placeholder="0 */6 * * * (every 6 hours)"
|
||||
value={syncIntervalCron}
|
||||
onChange={(e) => handleCronChange(e.target.value)}
|
||||
className="w-full"
|
||||
autoFocus
|
||||
onFocus={() => setCronValidationError('')}
|
||||
/>
|
||||
{cronValidationError && (
|
||||
<p className="text-sm text-red-500 mt-1">{cronValidationError}</p>
|
||||
)}
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
Format: minute hour day month weekday. See{' '}
|
||||
<a href="https://crontab.guru" target="_blank" rel="noopener noreferrer" className="text-primary hover:underline">
|
||||
crontab.guru
|
||||
</a>{' '}
|
||||
for examples
|
||||
</p>
|
||||
<div className="mt-2 p-2 bg-muted rounded text-xs">
|
||||
<p className="font-medium mb-1">Common examples:</p>
|
||||
<ul className="space-y-1 text-muted-foreground">
|
||||
<li>• <code>* * * * *</code> - Every minute</li>
|
||||
<li>• <code>0 * * * *</code> - Every hour</li>
|
||||
<li>• <code>0 */6 * * *</code> - Every 6 hours</li>
|
||||
<li>• <code>0 0 * * *</code> - Every day at midnight</li>
|
||||
<li>• <code>0 0 * * 0</code> - Every Sunday at midnight</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Auto-Download Options */}
|
||||
{autoSyncEnabled && (
|
||||
<div className="p-4 border border-border rounded-lg mb-4">
|
||||
<h4 className="font-medium text-foreground mb-3">Auto-Download Options</h4>
|
||||
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h5 className="font-medium text-foreground">Auto-download new scripts</h5>
|
||||
<p className="text-sm text-muted-foreground">Automatically download scripts that haven't been downloaded yet</p>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={autoDownloadNew}
|
||||
onCheckedChange={setAutoDownloadNew}
|
||||
disabled={isSaving}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h5 className="font-medium text-foreground">Auto-update existing scripts</h5>
|
||||
<p className="text-sm text-muted-foreground">Automatically update scripts that have newer versions available</p>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={autoUpdateExisting}
|
||||
onCheckedChange={setAutoUpdateExisting}
|
||||
disabled={isSaving}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Notifications */}
|
||||
{autoSyncEnabled && (
|
||||
<div className="p-4 border border-border rounded-lg mb-4">
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<div>
|
||||
<h4 className="font-medium text-foreground">Enable Notifications</h4>
|
||||
<p className="text-sm text-muted-foreground">Send notifications when sync completes</p>
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
If you want any other notification service, please open an issue on the GitHub repository.
|
||||
</p>
|
||||
</div>
|
||||
<Toggle
|
||||
checked={notificationEnabled}
|
||||
onCheckedChange={setNotificationEnabled}
|
||||
disabled={isSaving}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{notificationEnabled && (
|
||||
<div className="space-y-3">
|
||||
<div>
|
||||
<label htmlFor="apprise-urls" className="block text-sm font-medium text-foreground mb-1">
|
||||
Apprise URLs
|
||||
</label>
|
||||
<textarea
|
||||
id="apprise-urls"
|
||||
placeholder="http://YOUR_APPRISE_SERVER/notify/apprise "
|
||||
value={appriseUrlsText}
|
||||
onChange={(e) => handleAppriseUrlsChange(e.target.value)}
|
||||
className="w-full p-2 border border-border rounded-md bg-background h-24 resize-none"
|
||||
rows={3}
|
||||
/>
|
||||
<p className="text-xs text-muted-foreground mt-1">
|
||||
One URL per line. Supports Discord, Telegram, Email, Slack, and more via{' '}
|
||||
<a href="https://github.com/caronc/apprise" target="_blank" rel="noopener noreferrer" className="text-primary hover:underline">
|
||||
Apprise
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
onClick={testNotification}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={appriseUrls.length === 0}
|
||||
>
|
||||
Test Notification
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Status and Actions */}
|
||||
{autoSyncEnabled && (
|
||||
<div className="p-4 border border-border rounded-lg mb-4">
|
||||
<h4 className="font-medium text-foreground mb-3">Status & Actions</h4>
|
||||
|
||||
<div className="space-y-3">
|
||||
{lastAutoSync && (
|
||||
<div>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Last sync: {new Date(lastAutoSync).toLocaleString()}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
onClick={triggerManualSync}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
>
|
||||
Trigger Sync Now
|
||||
</Button>
|
||||
<Button
|
||||
onClick={saveAutoSyncSettings}
|
||||
disabled={isSaving || (syncIntervalType === 'custom' && !!cronValidationError)}
|
||||
size="sm"
|
||||
>
|
||||
{isSaving ? 'Saving...' : 'Save Settings'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Message Display */}
|
||||
{message && (
|
||||
<div className={`p-3 rounded-md text-sm ${
|
||||
message.type === 'success'
|
||||
? 'bg-success/10 text-success-foreground border border-success/20'
|
||||
: 'bg-error/10 text-error-foreground border border-error/20'
|
||||
}`}>
|
||||
{message.text}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Button } from './ui/button';
|
||||
import { HelpCircle, Server, Settings, RefreshCw, Clock, Package, HardDrive, FolderOpen, Search, Download } from 'lucide-react';
|
||||
import { HelpCircle, Server, Settings, RefreshCw, Package, HardDrive, FolderOpen, Search, Download } from 'lucide-react';
|
||||
import { useRegisterModal } from './modal/ModalStackProvider';
|
||||
|
||||
interface HelpModalProps {
|
||||
@@ -11,7 +11,7 @@ interface HelpModalProps {
|
||||
initialSection?: string;
|
||||
}
|
||||
|
||||
type HelpSection = 'server-settings' | 'general-settings' | 'sync-button' | 'auto-sync' | 'available-scripts' | 'downloaded-scripts' | 'installed-scripts' | 'lxc-settings' | 'update-system';
|
||||
type HelpSection = 'server-settings' | 'general-settings' | 'sync-button' | 'available-scripts' | 'downloaded-scripts' | 'installed-scripts' | 'lxc-settings' | 'update-system';
|
||||
|
||||
export function HelpModal({ isOpen, onClose, initialSection = 'server-settings' }: HelpModalProps) {
|
||||
useRegisterModal(isOpen, { id: 'help-modal', allowEscape: true, onClose });
|
||||
@@ -23,7 +23,6 @@ export function HelpModal({ isOpen, onClose, initialSection = 'server-settings'
|
||||
{ id: 'server-settings' as HelpSection, label: 'Server Settings', icon: Server },
|
||||
{ id: 'general-settings' as HelpSection, label: 'General Settings', icon: Settings },
|
||||
{ id: 'sync-button' as HelpSection, label: 'Sync Button', icon: RefreshCw },
|
||||
{ id: 'auto-sync' as HelpSection, label: 'Auto-Sync', icon: Clock },
|
||||
{ id: 'available-scripts' as HelpSection, label: 'Available Scripts', icon: Package },
|
||||
{ id: 'downloaded-scripts' as HelpSection, label: 'Downloaded Scripts', icon: HardDrive },
|
||||
{ id: 'installed-scripts' as HelpSection, label: 'Installed Scripts', icon: FolderOpen },
|
||||
@@ -186,101 +185,6 @@ export function HelpModal({ isOpen, onClose, initialSection = 'server-settings'
|
||||
</div>
|
||||
);
|
||||
|
||||
case 'auto-sync':
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h3 className="text-xl font-semibold text-foreground mb-4">Auto-Sync</h3>
|
||||
<p className="text-muted-foreground mb-6">
|
||||
Configure automatic synchronization of scripts with configurable intervals and notifications.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="p-4 border border-border rounded-lg">
|
||||
<h4 className="font-medium text-foreground mb-2">What Is Auto-Sync?</h4>
|
||||
<p className="text-sm text-muted-foreground mb-2">
|
||||
Auto-sync automatically synchronizes script metadata from the ProxmoxVE GitHub repository at specified intervals,
|
||||
and optionally downloads/updates scripts and sends notifications.
|
||||
</p>
|
||||
<ul className="text-sm text-muted-foreground space-y-1">
|
||||
<li>• <strong>Automatic JSON Sync:</strong> Downloads latest script metadata periodically</li>
|
||||
<li>• <strong>Auto-Download:</strong> Automatically download new scripts when available</li>
|
||||
<li>• <strong>Auto-Update:</strong> Automatically update existing scripts to newer versions</li>
|
||||
<li>• <strong>Notifications:</strong> Send notifications when sync completes</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="p-4 border border-border rounded-lg">
|
||||
<h4 className="font-medium text-foreground mb-2">Sync Intervals</h4>
|
||||
<ul className="text-sm text-muted-foreground space-y-2">
|
||||
<li>• <strong>Predefined:</strong> Choose from common intervals (15min, 30min, 1hour, 6hours, 12hours, 24hours)</li>
|
||||
<li>• <strong>Custom Cron:</strong> Use cron expressions for advanced scheduling</li>
|
||||
<li>• <strong>Examples:</strong>
|
||||
<ul className="ml-4 mt-1 space-y-1">
|
||||
<li>• <code>0 */6 * * *</code> - Every 6 hours</li>
|
||||
<li>• <code>0 0 * * *</code> - Daily at midnight</li>
|
||||
<li>• <code>0 9 * * 1</code> - Every Monday at 9 AM</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="p-4 border border-border rounded-lg">
|
||||
<h4 className="font-medium text-foreground mb-2">Auto-Download Options</h4>
|
||||
<ul className="text-sm text-muted-foreground space-y-2">
|
||||
<li>• <strong>Auto-download new scripts:</strong> Automatically download scripts that haven't been downloaded yet</li>
|
||||
<li>• <strong>Auto-update existing scripts:</strong> Automatically update scripts that have newer versions available</li>
|
||||
<li>• <strong>Selective Control:</strong> Enable/disable each option independently</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div className="p-4 border border-border rounded-lg">
|
||||
<h4 className="font-medium text-foreground mb-2">Notifications (Apprise)</h4>
|
||||
<p className="text-sm text-muted-foreground mb-2">
|
||||
Send notifications when sync completes using Apprise, which supports 80+ notification services.
|
||||
If you want any other notification service, please open an issue on the GitHub repository.
|
||||
</p>
|
||||
<ul className="text-sm text-muted-foreground space-y-2">
|
||||
<li>• <strong>Apprise Server:</strong> <code>http://YOUR_APPRISE_SERVER/notify/apprise</code></li>
|
||||
</ul>
|
||||
<p className="text-xs text-muted-foreground mt-2">
|
||||
See the <a href="https://github.com/caronc/apprise" target="_blank" rel="noopener noreferrer" className="text-primary hover:underline">Apprise documentation</a> for more supported services.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="p-4 border border-border rounded-lg">
|
||||
<h4 className="font-medium text-foreground mb-2">Setup Guide</h4>
|
||||
<ol className="text-sm text-muted-foreground space-y-2 list-decimal list-inside">
|
||||
<li>Enable auto-sync in the General Settings → Auto-Sync tab</li>
|
||||
<li>Choose your sync interval (predefined or custom cron)</li>
|
||||
<li>Configure auto-download options if desired</li>
|
||||
<li>Set up notifications by adding Apprise URLs</li>
|
||||
<li>Test your notification setup using the "Test Notification" button</li>
|
||||
<li>Save your settings to activate auto-sync</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div className="p-4 border border-border rounded-lg">
|
||||
<h4 className="font-medium text-foreground mb-2">Cron Expression Help</h4>
|
||||
<p className="text-sm text-muted-foreground mb-2">
|
||||
Cron expressions have 5 fields: minute hour day month weekday
|
||||
</p>
|
||||
<ul className="text-sm text-muted-foreground space-y-1">
|
||||
<li>• <strong>Minute:</strong> 0-59 or *</li>
|
||||
<li>• <strong>Hour:</strong> 0-23 or *</li>
|
||||
<li>• <strong>Day:</strong> 1-31 or *</li>
|
||||
<li>• <strong>Month:</strong> 1-12 or *</li>
|
||||
<li>• <strong>Weekday:</strong> 0-6 (Sunday=0) or *</li>
|
||||
</ul>
|
||||
<p className="text-xs text-muted-foreground mt-2">
|
||||
Use <a href="https://crontab.guru" target="_blank" rel="noopener noreferrer" className="text-primary hover:underline">crontab.guru</a> to test and learn cron expressions.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
case 'available-scripts':
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
|
||||
@@ -1,379 +0,0 @@
|
||||
import type { NextRequest } from 'next/server';
|
||||
import { NextResponse } from 'next/server';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { isValidCron } from 'cron-validator';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const settings = await request.json();
|
||||
|
||||
if (!settings || typeof settings !== 'object') {
|
||||
return NextResponse.json(
|
||||
{ error: 'Settings object is required' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Handle test notification request
|
||||
if (settings.testNotification) {
|
||||
return await handleTestNotification();
|
||||
}
|
||||
|
||||
// Handle manual sync trigger
|
||||
if (settings.triggerManualSync) {
|
||||
return await handleManualSync();
|
||||
}
|
||||
|
||||
// Validate required fields for settings save
|
||||
const requiredFields = [
|
||||
'autoSyncEnabled',
|
||||
'syncIntervalType',
|
||||
'autoDownloadNew',
|
||||
'autoUpdateExisting',
|
||||
'notificationEnabled'
|
||||
];
|
||||
|
||||
for (const field of requiredFields) {
|
||||
if (!(field in settings)) {
|
||||
return NextResponse.json(
|
||||
{ error: `Missing required field: ${field}` },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate sync interval type
|
||||
if (!['predefined', 'custom'].includes(settings.syncIntervalType)) {
|
||||
return NextResponse.json(
|
||||
{ error: 'syncIntervalType must be "predefined" or "custom"' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Validate predefined interval
|
||||
if (settings.syncIntervalType === 'predefined') {
|
||||
const validIntervals = ['15min', '30min', '1hour', '6hours', '12hours', '24hours'];
|
||||
if (!validIntervals.includes(settings.syncIntervalPredefined)) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Invalid predefined interval' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate custom cron expression
|
||||
if (settings.syncIntervalType === 'custom') {
|
||||
if (!settings.syncIntervalCron || typeof settings.syncIntervalCron !== 'string') {
|
||||
return NextResponse.json(
|
||||
{ error: 'Custom cron expression is required when syncIntervalType is "custom"' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
if (!isValidCron(settings.syncIntervalCron, { seconds: false })) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Invalid cron expression' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Validate Apprise URLs if notifications are enabled
|
||||
if (settings.notificationEnabled && settings.appriseUrls) {
|
||||
try {
|
||||
// Handle both array and JSON string formats
|
||||
let urls;
|
||||
if (Array.isArray(settings.appriseUrls)) {
|
||||
urls = settings.appriseUrls;
|
||||
} else if (typeof settings.appriseUrls === 'string') {
|
||||
urls = JSON.parse(settings.appriseUrls);
|
||||
} else {
|
||||
return NextResponse.json(
|
||||
{ error: 'Apprise URLs must be an array or JSON string' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
if (!Array.isArray(urls)) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Apprise URLs must be an array' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Basic URL validation
|
||||
for (const url of urls) {
|
||||
if (typeof url !== 'string' || url.trim() === '') {
|
||||
return NextResponse.json(
|
||||
{ error: 'All Apprise URLs must be non-empty strings' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (parseError) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Invalid JSON format for Apprise URLs' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Path to the .env file
|
||||
const envPath = path.join(process.cwd(), '.env');
|
||||
|
||||
// Read existing .env file
|
||||
let envContent = '';
|
||||
if (fs.existsSync(envPath)) {
|
||||
envContent = fs.readFileSync(envPath, 'utf8');
|
||||
}
|
||||
|
||||
// Auto-sync settings to add/update
|
||||
const autoSyncSettings = {
|
||||
'AUTO_SYNC_ENABLED': settings.autoSyncEnabled ? 'true' : 'false',
|
||||
'SYNC_INTERVAL_TYPE': settings.syncIntervalType,
|
||||
'SYNC_INTERVAL_PREDEFINED': settings.syncIntervalPredefined || '',
|
||||
'SYNC_INTERVAL_CRON': settings.syncIntervalCron || '',
|
||||
'AUTO_DOWNLOAD_NEW': settings.autoDownloadNew ? 'true' : 'false',
|
||||
'AUTO_UPDATE_EXISTING': settings.autoUpdateExisting ? 'true' : 'false',
|
||||
'NOTIFICATION_ENABLED': settings.notificationEnabled ? 'true' : 'false',
|
||||
'APPRISE_URLS': Array.isArray(settings.appriseUrls) ? JSON.stringify(settings.appriseUrls) : (settings.appriseUrls || '[]'),
|
||||
'LAST_AUTO_SYNC': settings.lastAutoSync || ''
|
||||
};
|
||||
|
||||
// Update or add each setting
|
||||
for (const [key, value] of Object.entries(autoSyncSettings)) {
|
||||
const regex = new RegExp(`^${key}=.*$`, 'm');
|
||||
const settingLine = `${key}="${value}"`;
|
||||
|
||||
if (regex.test(envContent)) {
|
||||
// Replace existing setting
|
||||
envContent = envContent.replace(regex, settingLine);
|
||||
} else {
|
||||
// Add new setting
|
||||
envContent += (envContent.endsWith('\n') ? '' : '\n') + `${settingLine}\n`;
|
||||
}
|
||||
}
|
||||
|
||||
// Write back to .env file
|
||||
fs.writeFileSync(envPath, envContent);
|
||||
|
||||
// Reschedule auto-sync service with new settings
|
||||
try {
|
||||
const { AutoSyncService } = await import('../../../../server/services/autoSyncService.js');
|
||||
const autoSyncService = new AutoSyncService();
|
||||
|
||||
if (settings.autoSyncEnabled) {
|
||||
autoSyncService.scheduleAutoSync();
|
||||
console.log('Auto-sync rescheduled with new settings');
|
||||
} else {
|
||||
autoSyncService.stopAutoSync();
|
||||
console.log('Auto-sync stopped');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error rescheduling auto-sync service:', error);
|
||||
// Don't fail the request if rescheduling fails
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: 'Auto-sync settings saved successfully'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error saving auto-sync settings:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to save auto-sync settings' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
// Path to the .env file
|
||||
const envPath = path.join(process.cwd(), '.env');
|
||||
|
||||
if (!fs.existsSync(envPath)) {
|
||||
return NextResponse.json({
|
||||
settings: {
|
||||
autoSyncEnabled: false,
|
||||
syncIntervalType: 'predefined',
|
||||
syncIntervalPredefined: '1hour',
|
||||
syncIntervalCron: '',
|
||||
autoDownloadNew: false,
|
||||
autoUpdateExisting: false,
|
||||
notificationEnabled: false,
|
||||
appriseUrls: [],
|
||||
lastAutoSync: ''
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Read .env file and extract auto-sync settings
|
||||
const envContent = fs.readFileSync(envPath, 'utf8');
|
||||
|
||||
const settings = {
|
||||
autoSyncEnabled: getEnvValue(envContent, 'AUTO_SYNC_ENABLED') === 'true',
|
||||
syncIntervalType: getEnvValue(envContent, 'SYNC_INTERVAL_TYPE') || 'predefined',
|
||||
syncIntervalPredefined: getEnvValue(envContent, 'SYNC_INTERVAL_PREDEFINED') || '1hour',
|
||||
syncIntervalCron: getEnvValue(envContent, 'SYNC_INTERVAL_CRON') || '',
|
||||
autoDownloadNew: getEnvValue(envContent, 'AUTO_DOWNLOAD_NEW') === 'true',
|
||||
autoUpdateExisting: getEnvValue(envContent, 'AUTO_UPDATE_EXISTING') === 'true',
|
||||
notificationEnabled: getEnvValue(envContent, 'NOTIFICATION_ENABLED') === 'true',
|
||||
appriseUrls: (() => {
|
||||
try {
|
||||
const urlsValue = getEnvValue(envContent, 'APPRISE_URLS') || '[]';
|
||||
return JSON.parse(urlsValue);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
})(),
|
||||
lastAutoSync: getEnvValue(envContent, 'LAST_AUTO_SYNC') || ''
|
||||
};
|
||||
|
||||
return NextResponse.json({ settings });
|
||||
} catch (error) {
|
||||
console.error('Error reading auto-sync settings:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to read auto-sync settings' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to handle test notification
|
||||
async function handleTestNotification() {
|
||||
try {
|
||||
// Load current settings
|
||||
const envPath = path.join(process.cwd(), '.env');
|
||||
|
||||
if (!fs.existsSync(envPath)) {
|
||||
return NextResponse.json(
|
||||
{ error: 'No auto-sync settings found' },
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
const envContent = fs.readFileSync(envPath, 'utf8');
|
||||
const notificationEnabled = getEnvValue(envContent, 'NOTIFICATION_ENABLED') === 'true';
|
||||
const appriseUrls = (() => {
|
||||
try {
|
||||
const urlsValue = getEnvValue(envContent, 'APPRISE_URLS') || '[]';
|
||||
return JSON.parse(urlsValue);
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
})();
|
||||
|
||||
if (!notificationEnabled) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Notifications are not enabled' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
if (!appriseUrls || appriseUrls.length === 0) {
|
||||
return NextResponse.json(
|
||||
{ error: 'No Apprise URLs configured' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Send test notification using the auto-sync service
|
||||
const { AutoSyncService } = await import('../../../../server/services/autoSyncService.js');
|
||||
const autoSyncService = new AutoSyncService();
|
||||
const result = await autoSyncService.testNotification();
|
||||
|
||||
if (result.success) {
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: 'Test notification sent successfully'
|
||||
});
|
||||
} else {
|
||||
return NextResponse.json(
|
||||
{ error: result.message },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error sending test notification:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to send test notification' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to handle manual sync trigger
|
||||
async function handleManualSync() {
|
||||
try {
|
||||
// Load current settings
|
||||
const envPath = path.join(process.cwd(), '.env');
|
||||
|
||||
if (!fs.existsSync(envPath)) {
|
||||
return NextResponse.json(
|
||||
{ error: 'No auto-sync settings found' },
|
||||
{ status: 404 }
|
||||
);
|
||||
}
|
||||
|
||||
const envContent = fs.readFileSync(envPath, 'utf8');
|
||||
const autoSyncEnabled = getEnvValue(envContent, 'AUTO_SYNC_ENABLED') === 'true';
|
||||
|
||||
if (!autoSyncEnabled) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Auto-sync is not enabled' },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
// Trigger manual sync using the auto-sync service
|
||||
const { AutoSyncService } = await import('../../../../server/services/autoSyncService.js');
|
||||
const autoSyncService = new AutoSyncService();
|
||||
const result = await autoSyncService.executeAutoSync() as any;
|
||||
|
||||
if (result && result.success) {
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: 'Manual sync completed successfully',
|
||||
result
|
||||
});
|
||||
} else {
|
||||
return NextResponse.json(
|
||||
{ error: result.message },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error triggering manual sync:', error);
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to trigger manual sync' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to extract value from .env content
|
||||
function getEnvValue(envContent: string, key: string): string {
|
||||
// Try to match the pattern with quotes around the value (handles nested quotes)
|
||||
const regex = new RegExp(`^${key}="(.+)"$`, 'm');
|
||||
let match = regex.exec(envContent);
|
||||
|
||||
if (match && match[1]) {
|
||||
let value = match[1];
|
||||
// Remove extra quotes that might be around JSON values
|
||||
if (value.startsWith('"') && value.endsWith('"')) {
|
||||
value = value.slice(1, -1);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// Try to match without quotes (fallback)
|
||||
const regexNoQuotes = new RegExp(`^${key}=([^\\s]*)$`, 'm');
|
||||
match = regexNoQuotes.exec(envContent);
|
||||
if (match && match[1]) {
|
||||
return match[1];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { scriptManager } from "~/server/lib/scripts";
|
||||
import { githubJsonService } from "~/server/services/githubJsonService";
|
||||
import { localScriptsService } from "~/server/services/localScripts";
|
||||
import { scriptDownloaderService } from "~/server/services/scriptDownloader";
|
||||
import { AutoSyncService } from "~/server/services/autoSyncService";
|
||||
import type { ScriptCard } from "~/types/script";
|
||||
|
||||
export const scriptsRouter = createTRPCRouter({
|
||||
@@ -458,106 +457,5 @@ export const scriptsRouter = createTRPCRouter({
|
||||
message: 'Failed to check Proxmox VE status'
|
||||
};
|
||||
}
|
||||
}),
|
||||
|
||||
// Auto-sync settings and operations
|
||||
getAutoSyncSettings: publicProcedure
|
||||
.query(async () => {
|
||||
try {
|
||||
const autoSyncService = new AutoSyncService();
|
||||
const settings = autoSyncService.loadSettings();
|
||||
return { success: true, settings };
|
||||
} catch (error) {
|
||||
console.error('Error getting auto-sync settings:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to get auto-sync settings',
|
||||
settings: null
|
||||
};
|
||||
}
|
||||
}),
|
||||
|
||||
saveAutoSyncSettings: publicProcedure
|
||||
.input(z.object({
|
||||
autoSyncEnabled: z.boolean(),
|
||||
syncIntervalType: z.enum(['predefined', 'custom']),
|
||||
syncIntervalPredefined: z.string().optional(),
|
||||
syncIntervalCron: z.string().optional(),
|
||||
autoDownloadNew: z.boolean(),
|
||||
autoUpdateExisting: z.boolean(),
|
||||
notificationEnabled: z.boolean(),
|
||||
appriseUrls: z.array(z.string()).optional()
|
||||
}))
|
||||
.mutation(async ({ input }) => {
|
||||
try {
|
||||
const autoSyncService = new AutoSyncService();
|
||||
autoSyncService.saveSettings(input);
|
||||
|
||||
// Reschedule auto-sync if enabled
|
||||
if (input.autoSyncEnabled) {
|
||||
autoSyncService.scheduleAutoSync();
|
||||
} else {
|
||||
autoSyncService.stopAutoSync();
|
||||
}
|
||||
|
||||
return { success: true, message: 'Auto-sync settings saved successfully' };
|
||||
} catch (error) {
|
||||
console.error('Error saving auto-sync settings:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to save auto-sync settings'
|
||||
};
|
||||
}
|
||||
}),
|
||||
|
||||
testNotification: publicProcedure
|
||||
.mutation(async () => {
|
||||
try {
|
||||
const autoSyncService = new AutoSyncService();
|
||||
const result = await autoSyncService.testNotification();
|
||||
return result;
|
||||
} catch (error) {
|
||||
console.error('Error testing notification:', error);
|
||||
return {
|
||||
success: false,
|
||||
message: error instanceof Error ? error.message : 'Failed to test notification'
|
||||
};
|
||||
}
|
||||
}),
|
||||
|
||||
triggerManualAutoSync: publicProcedure
|
||||
.mutation(async () => {
|
||||
try {
|
||||
const autoSyncService = new AutoSyncService();
|
||||
const result = await autoSyncService.executeAutoSync();
|
||||
return {
|
||||
success: true,
|
||||
message: 'Manual auto-sync completed successfully',
|
||||
result
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error in manual auto-sync:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to execute manual auto-sync',
|
||||
result: null
|
||||
};
|
||||
}
|
||||
}),
|
||||
|
||||
getAutoSyncStatus: publicProcedure
|
||||
.query(async () => {
|
||||
try {
|
||||
const autoSyncService = new AutoSyncService();
|
||||
const status = autoSyncService.getStatus();
|
||||
return { success: true, status };
|
||||
} catch (error) {
|
||||
console.error('Error getting auto-sync status:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'Failed to get auto-sync status',
|
||||
status: null
|
||||
};
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
import { AutoSyncService } from '../services/autoSyncService.js';
|
||||
|
||||
let autoSyncService = null;
|
||||
|
||||
/**
|
||||
* Initialize auto-sync service and schedule cron job if enabled
|
||||
*/
|
||||
export function initializeAutoSync() {
|
||||
try {
|
||||
console.log('Initializing auto-sync service...');
|
||||
autoSyncService = new AutoSyncService();
|
||||
|
||||
// Load settings and schedule if enabled
|
||||
const settings = autoSyncService.loadSettings();
|
||||
|
||||
if (settings.autoSyncEnabled) {
|
||||
console.log('Auto-sync is enabled, scheduling cron job...');
|
||||
autoSyncService.scheduleAutoSync();
|
||||
} else {
|
||||
console.log('Auto-sync is disabled');
|
||||
}
|
||||
|
||||
console.log('Auto-sync service initialized successfully');
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize auto-sync service:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop auto-sync service and clean up cron jobs
|
||||
*/
|
||||
export function stopAutoSync() {
|
||||
try {
|
||||
if (autoSyncService) {
|
||||
console.log('Stopping auto-sync service...');
|
||||
autoSyncService.stopAutoSync();
|
||||
autoSyncService = null;
|
||||
console.log('Auto-sync service stopped');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error stopping auto-sync service:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the auto-sync service instance
|
||||
*/
|
||||
export function getAutoSyncService() {
|
||||
return autoSyncService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Graceful shutdown handler
|
||||
*/
|
||||
export function setupGracefulShutdown() {
|
||||
const shutdown = (signal) => {
|
||||
console.log(`Received ${signal}, shutting down gracefully...`);
|
||||
stopAutoSync();
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
||||
process.on('SIGINT', () => shutdown('SIGINT'));
|
||||
process.on('SIGUSR2', () => shutdown('SIGUSR2')); // For nodemon
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
import { AutoSyncService } from '~/server/services/autoSyncService';
|
||||
|
||||
let autoSyncService: AutoSyncService | null = null;
|
||||
|
||||
/**
|
||||
* Initialize auto-sync service and schedule cron job if enabled
|
||||
*/
|
||||
export function initializeAutoSync(): void {
|
||||
try {
|
||||
console.log('Initializing auto-sync service...');
|
||||
autoSyncService = new AutoSyncService();
|
||||
|
||||
// Load settings and schedule if enabled
|
||||
const settings = autoSyncService.loadSettings();
|
||||
|
||||
if (settings.autoSyncEnabled) {
|
||||
console.log('Auto-sync is enabled, scheduling cron job...');
|
||||
autoSyncService.scheduleAutoSync();
|
||||
} else {
|
||||
console.log('Auto-sync is disabled');
|
||||
}
|
||||
|
||||
console.log('Auto-sync service initialized successfully');
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize auto-sync service:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop auto-sync service and clean up cron jobs
|
||||
*/
|
||||
export function stopAutoSync(): void {
|
||||
try {
|
||||
if (autoSyncService) {
|
||||
console.log('Stopping auto-sync service...');
|
||||
autoSyncService.stopAutoSync();
|
||||
autoSyncService = null;
|
||||
console.log('Auto-sync service stopped');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error stopping auto-sync service:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the auto-sync service instance
|
||||
*/
|
||||
export function getAutoSyncService(): AutoSyncService | null {
|
||||
return autoSyncService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Graceful shutdown handler
|
||||
*/
|
||||
export function setupGracefulShutdown(): void {
|
||||
const shutdown = (signal: string) => {
|
||||
console.log(`Received ${signal}, shutting down gracefully...`);
|
||||
stopAutoSync();
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
process.on('SIGTERM', () => shutdown('SIGTERM'));
|
||||
process.on('SIGINT', () => shutdown('SIGINT'));
|
||||
process.on('SIGUSR2', () => shutdown('SIGUSR2')); // For nodemon
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
import axios from 'axios';
|
||||
|
||||
export class AppriseService {
|
||||
constructor() {
|
||||
this.baseUrl = 'http://localhost:8080'; // Default Apprise API URL
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notification via Apprise
|
||||
* @param {string} title - Notification title
|
||||
* @param {string} body - Notification body
|
||||
* @param {string[]} urls - Array of Apprise URLs
|
||||
*/
|
||||
async sendNotification(title, body, urls) {
|
||||
if (!urls || urls.length === 0) {
|
||||
throw new Error('No Apprise URLs provided');
|
||||
}
|
||||
|
||||
try {
|
||||
// Format the notification as form data (Apprise API expects form data)
|
||||
const formData = new URLSearchParams();
|
||||
formData.append('body', body || '');
|
||||
formData.append('title', title || 'PVE Scripts Local');
|
||||
formData.append('tags', 'all');
|
||||
|
||||
// Send to each URL
|
||||
const results = [];
|
||||
for (const url of urls) {
|
||||
try {
|
||||
const response = await axios.post(url, formData, {
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
timeout: 10000 // 10 second timeout
|
||||
});
|
||||
|
||||
results.push({
|
||||
url,
|
||||
success: true,
|
||||
status: response.status
|
||||
});
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
console.error(`Failed to send notification to ${url}:`, errorMessage);
|
||||
results.push({
|
||||
url,
|
||||
success: false,
|
||||
error: errorMessage
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Check if any notifications succeeded
|
||||
const successCount = results.filter(r => r.success).length;
|
||||
if (successCount === 0) {
|
||||
throw new Error('All notification attempts failed');
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `Notification sent to ${successCount}/${urls.length} services`,
|
||||
results
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.error('Apprise notification failed:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test notification to a single URL
|
||||
* @param {string} url - Apprise URL to test
|
||||
*/
|
||||
async testUrl(url) {
|
||||
try {
|
||||
await this.sendNotification('Test', 'This is a test notification', [url]);
|
||||
return { success: true, message: 'Test notification sent successfully' };
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
return { success: false, message: errorMessage };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate Apprise URL format
|
||||
* @param {string} url - URL to validate
|
||||
*/
|
||||
validateUrl(url) {
|
||||
if (!url || typeof url !== 'string') {
|
||||
return { valid: false, error: 'URL is required' };
|
||||
}
|
||||
|
||||
// Basic URL validation
|
||||
try {
|
||||
new URL(url);
|
||||
} catch {
|
||||
return { valid: false, error: 'Invalid URL format' };
|
||||
}
|
||||
|
||||
// Check for common Apprise URL patterns
|
||||
const apprisePatterns = [
|
||||
/^discord:\/\//,
|
||||
/^tgram:\/\//,
|
||||
/^mailto:\/\//,
|
||||
/^slack:\/\//,
|
||||
/^https?:\/\//
|
||||
];
|
||||
|
||||
const isValidAppriseUrl = apprisePatterns.some(pattern => pattern.test(url));
|
||||
|
||||
if (!isValidAppriseUrl) {
|
||||
return {
|
||||
valid: false,
|
||||
error: 'URL does not match known Apprise service patterns'
|
||||
};
|
||||
}
|
||||
|
||||
return { valid: true };
|
||||
}
|
||||
}
|
||||
|
||||
export const appriseService = new AppriseService();
|
||||
@@ -1,542 +0,0 @@
|
||||
import cron from 'node-cron';
|
||||
import { githubJsonService } from './githubJsonService.js';
|
||||
import { scriptDownloaderService } from './scriptDownloader.js';
|
||||
import { appriseService } from './appriseService.js';
|
||||
import { readFile, writeFile, readFileSync, writeFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import cronValidator from 'cron-validator';
|
||||
|
||||
export class AutoSyncService {
|
||||
constructor() {
|
||||
this.cronJob = null;
|
||||
this.isRunning = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load auto-sync settings from .env file
|
||||
*/
|
||||
loadSettings() {
|
||||
try {
|
||||
const envPath = join(process.cwd(), '.env');
|
||||
const envContent = readFileSync(envPath, 'utf8');
|
||||
|
||||
const settings = {
|
||||
autoSyncEnabled: false,
|
||||
syncIntervalType: 'predefined',
|
||||
syncIntervalPredefined: '1hour',
|
||||
syncIntervalCron: '',
|
||||
autoDownloadNew: false,
|
||||
autoUpdateExisting: false,
|
||||
notificationEnabled: false,
|
||||
appriseUrls: [],
|
||||
lastAutoSync: ''
|
||||
};
|
||||
const lines = envContent.split('\n');
|
||||
|
||||
for (const line of lines) {
|
||||
const [key, ...valueParts] = line.split('=');
|
||||
if (key && valueParts.length > 0) {
|
||||
let value = valueParts.join('=').trim();
|
||||
// Remove surrounding quotes if present
|
||||
if (value.startsWith('"') && value.endsWith('"')) {
|
||||
value = value.slice(1, -1);
|
||||
}
|
||||
|
||||
switch (key.trim()) {
|
||||
case 'AUTO_SYNC_ENABLED':
|
||||
settings.autoSyncEnabled = value === 'true';
|
||||
break;
|
||||
case 'SYNC_INTERVAL_TYPE':
|
||||
settings.syncIntervalType = value;
|
||||
break;
|
||||
case 'SYNC_INTERVAL_PREDEFINED':
|
||||
settings.syncIntervalPredefined = value;
|
||||
break;
|
||||
case 'SYNC_INTERVAL_CRON':
|
||||
settings.syncIntervalCron = value;
|
||||
break;
|
||||
case 'AUTO_DOWNLOAD_NEW':
|
||||
settings.autoDownloadNew = value === 'true';
|
||||
break;
|
||||
case 'AUTO_UPDATE_EXISTING':
|
||||
settings.autoUpdateExisting = value === 'true';
|
||||
break;
|
||||
case 'NOTIFICATION_ENABLED':
|
||||
settings.notificationEnabled = value === 'true';
|
||||
break;
|
||||
case 'APPRISE_URLS':
|
||||
try {
|
||||
settings.appriseUrls = JSON.parse(value || '[]');
|
||||
} catch {
|
||||
settings.appriseUrls = [];
|
||||
}
|
||||
break;
|
||||
case 'LAST_AUTO_SYNC':
|
||||
settings.lastAutoSync = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
} catch (error) {
|
||||
console.error('Error loading auto-sync settings:', error);
|
||||
return {
|
||||
autoSyncEnabled: false,
|
||||
syncIntervalType: 'predefined',
|
||||
syncIntervalPredefined: '1hour',
|
||||
syncIntervalCron: '',
|
||||
autoDownloadNew: false,
|
||||
autoUpdateExisting: false,
|
||||
notificationEnabled: false,
|
||||
appriseUrls: [],
|
||||
lastAutoSync: ''
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save auto-sync settings to .env file
|
||||
* @param {Object} settings - Settings object
|
||||
* @param {boolean} settings.autoSyncEnabled
|
||||
* @param {string} settings.syncIntervalType
|
||||
* @param {string} [settings.syncIntervalPredefined]
|
||||
* @param {string} [settings.syncIntervalCron]
|
||||
* @param {boolean} settings.autoDownloadNew
|
||||
* @param {boolean} settings.autoUpdateExisting
|
||||
* @param {boolean} settings.notificationEnabled
|
||||
* @param {Array<string>} [settings.appriseUrls]
|
||||
* @param {string} [settings.lastAutoSync]
|
||||
*/
|
||||
saveSettings(settings) {
|
||||
try {
|
||||
const envPath = join(process.cwd(), '.env');
|
||||
let envContent = '';
|
||||
|
||||
try {
|
||||
envContent = readFileSync(envPath, 'utf8');
|
||||
} catch {
|
||||
// .env file doesn't exist, create it
|
||||
}
|
||||
|
||||
const lines = envContent.split('\n');
|
||||
const newLines = [];
|
||||
const settingsMap = {
|
||||
'AUTO_SYNC_ENABLED': settings.autoSyncEnabled.toString(),
|
||||
'SYNC_INTERVAL_TYPE': settings.syncIntervalType,
|
||||
'SYNC_INTERVAL_PREDEFINED': settings.syncIntervalPredefined || '',
|
||||
'SYNC_INTERVAL_CRON': settings.syncIntervalCron || '',
|
||||
'AUTO_DOWNLOAD_NEW': settings.autoDownloadNew.toString(),
|
||||
'AUTO_UPDATE_EXISTING': settings.autoUpdateExisting.toString(),
|
||||
'NOTIFICATION_ENABLED': settings.notificationEnabled.toString(),
|
||||
'APPRISE_URLS': JSON.stringify(settings.appriseUrls || []),
|
||||
'LAST_AUTO_SYNC': settings.lastAutoSync || ''
|
||||
};
|
||||
|
||||
const existingKeys = new Set();
|
||||
|
||||
for (const line of lines) {
|
||||
const [key] = line.split('=');
|
||||
const trimmedKey = key?.trim();
|
||||
if (trimmedKey && trimmedKey in settingsMap) {
|
||||
// @ts-ignore - Dynamic key access is safe here
|
||||
newLines.push(`${trimmedKey}=${settingsMap[trimmedKey]}`);
|
||||
existingKeys.add(trimmedKey);
|
||||
} else if (trimmedKey && !(trimmedKey in settingsMap)) {
|
||||
newLines.push(line);
|
||||
}
|
||||
}
|
||||
|
||||
// Add any missing settings
|
||||
for (const [key, value] of Object.entries(settingsMap)) {
|
||||
if (!existingKeys.has(key)) {
|
||||
newLines.push(`${key}=${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
writeFileSync(envPath, newLines.join('\n'));
|
||||
console.log('Auto-sync settings saved successfully');
|
||||
} catch (error) {
|
||||
console.error('Error saving auto-sync settings:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule auto-sync cron job
|
||||
*/
|
||||
scheduleAutoSync() {
|
||||
this.stopAutoSync(); // Stop any existing job
|
||||
|
||||
const settings = this.loadSettings();
|
||||
if (!settings.autoSyncEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
let cronExpression;
|
||||
|
||||
if (settings.syncIntervalType === 'custom') {
|
||||
cronExpression = settings.syncIntervalCron;
|
||||
} else {
|
||||
// Convert predefined intervals to cron expressions
|
||||
const intervalMap = {
|
||||
'15min': '*/15 * * * *',
|
||||
'30min': '*/30 * * * *',
|
||||
'1hour': '0 * * * *',
|
||||
'6hours': '0 */6 * * *',
|
||||
'12hours': '0 */12 * * *',
|
||||
'24hours': '0 0 * * *'
|
||||
};
|
||||
// @ts-ignore - Dynamic key access is safe here
|
||||
cronExpression = intervalMap[settings.syncIntervalPredefined] || '0 * * * *';
|
||||
}
|
||||
|
||||
// Validate cron expression (5-field format for node-cron)
|
||||
if (!cronValidator.isValidCron(cronExpression, { seconds: false })) {
|
||||
console.error('Invalid cron expression:', cronExpression);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`Scheduling auto-sync with cron expression: ${cronExpression}`);
|
||||
|
||||
this.cronJob = cron.schedule(cronExpression, async () => {
|
||||
if (this.isRunning) {
|
||||
console.log('Auto-sync already running, skipping...');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Starting scheduled auto-sync...');
|
||||
await this.executeAutoSync();
|
||||
}, {
|
||||
scheduled: true,
|
||||
timezone: 'UTC'
|
||||
});
|
||||
|
||||
console.log('Auto-sync cron job scheduled successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop auto-sync cron job
|
||||
*/
|
||||
stopAutoSync() {
|
||||
if (this.cronJob) {
|
||||
this.cronJob.stop();
|
||||
this.cronJob = null;
|
||||
console.log('Auto-sync cron job stopped');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute auto-sync process
|
||||
*/
|
||||
async executeAutoSync() {
|
||||
if (this.isRunning) {
|
||||
console.log('Auto-sync already running, skipping...');
|
||||
return { success: false, message: 'Auto-sync already running' };
|
||||
}
|
||||
|
||||
this.isRunning = true;
|
||||
const startTime = new Date();
|
||||
|
||||
try {
|
||||
console.log('Starting auto-sync execution...');
|
||||
|
||||
// Step 1: Sync JSON files
|
||||
console.log('Syncing JSON files...');
|
||||
const syncResult = await githubJsonService.syncJsonFiles();
|
||||
|
||||
if (!syncResult.success) {
|
||||
throw new Error(`JSON sync failed: ${syncResult.message}`);
|
||||
}
|
||||
|
||||
const results = {
|
||||
jsonSync: syncResult,
|
||||
newScripts: [],
|
||||
updatedScripts: [],
|
||||
errors: []
|
||||
};
|
||||
|
||||
// Step 2: Auto-download/update scripts if enabled
|
||||
const settings = this.loadSettings();
|
||||
|
||||
if (settings.autoDownloadNew || settings.autoUpdateExisting) {
|
||||
// Only process scripts for files that were actually synced
|
||||
// @ts-ignore - syncedFiles exists in the JavaScript version
|
||||
if (syncResult.syncedFiles && syncResult.syncedFiles.length > 0) {
|
||||
// @ts-ignore - syncedFiles exists in the JavaScript version
|
||||
console.log(`Processing ${syncResult.syncedFiles.length} synced JSON files for new scripts...`);
|
||||
|
||||
// Get all scripts from synced files
|
||||
// @ts-ignore - syncedFiles exists in the JavaScript version
|
||||
const allSyncedScripts = await githubJsonService.getScriptsForFiles(syncResult.syncedFiles);
|
||||
|
||||
// Initialize script downloader service
|
||||
// @ts-ignore - initializeConfig is public in the JS version
|
||||
scriptDownloaderService.initializeConfig();
|
||||
|
||||
// Filter to only truly NEW scripts (not previously downloaded)
|
||||
const newScripts = [];
|
||||
for (const script of allSyncedScripts) {
|
||||
const isDownloaded = await scriptDownloaderService.isScriptDownloaded(script);
|
||||
if (!isDownloaded) {
|
||||
newScripts.push(script);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Found ${newScripts.length} new scripts out of ${allSyncedScripts.length} total scripts`);
|
||||
|
||||
if (settings.autoDownloadNew && newScripts.length > 0) {
|
||||
console.log(`Auto-downloading ${newScripts.length} new scripts...`);
|
||||
const downloadResult = await scriptDownloaderService.autoDownloadNewScripts(newScripts);
|
||||
// @ts-ignore - Type assertion needed for dynamic assignment
|
||||
results.newScripts = downloadResult.downloaded;
|
||||
// @ts-ignore - Type assertion needed for dynamic assignment
|
||||
results.errors.push(...downloadResult.errors);
|
||||
}
|
||||
|
||||
if (settings.autoUpdateExisting) {
|
||||
console.log('Auto-updating existing scripts from synced files...');
|
||||
const updateResult = await scriptDownloaderService.autoUpdateExistingScripts(allSyncedScripts);
|
||||
// @ts-ignore - Type assertion needed for dynamic assignment
|
||||
results.updatedScripts = updateResult.updated;
|
||||
// @ts-ignore - Type assertion needed for dynamic assignment
|
||||
results.errors.push(...updateResult.errors);
|
||||
}
|
||||
} else {
|
||||
console.log('No JSON files were synced, skipping script download/update');
|
||||
}
|
||||
} else {
|
||||
console.log('Auto-download/update disabled, skipping script processing');
|
||||
}
|
||||
|
||||
// Step 3: Send notifications if enabled
|
||||
if (settings.notificationEnabled && settings.appriseUrls?.length > 0) {
|
||||
console.log('Sending notifications...');
|
||||
await this.sendSyncNotification(results);
|
||||
}
|
||||
|
||||
// Step 4: Update last sync time
|
||||
const lastSyncTime = new Date().toISOString();
|
||||
const updatedSettings = { ...settings, lastAutoSync: lastSyncTime };
|
||||
this.saveSettings(updatedSettings);
|
||||
|
||||
const duration = new Date().getTime() - startTime.getTime();
|
||||
console.log(`Auto-sync completed successfully in ${duration}ms`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'Auto-sync completed successfully',
|
||||
results,
|
||||
duration
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.error('Auto-sync execution failed:', error);
|
||||
|
||||
// Send error notification if enabled
|
||||
const settings = this.loadSettings();
|
||||
if (settings.notificationEnabled && settings.appriseUrls?.length > 0) {
|
||||
try {
|
||||
await appriseService.sendNotification(
|
||||
'Auto-Sync Failed',
|
||||
`Auto-sync failed with error: ${error instanceof Error ? error.message : String(error)}`,
|
||||
settings.appriseUrls
|
||||
);
|
||||
} catch (notifError) {
|
||||
console.error('Failed to send error notification:', notifError);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: error instanceof Error ? error.message : String(error),
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
};
|
||||
} finally {
|
||||
this.isRunning = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load categories from metadata.json
|
||||
*/
|
||||
loadCategories() {
|
||||
try {
|
||||
const metadataPath = join(process.cwd(), 'scripts', 'json', 'metadata.json');
|
||||
const metadataContent = readFileSync(metadataPath, 'utf8');
|
||||
const metadata = JSON.parse(metadataContent);
|
||||
return metadata.categories || [];
|
||||
} catch (error) {
|
||||
console.error('Error loading categories:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Group scripts by category
|
||||
* @param {Array<any>} scripts - Array of script objects
|
||||
* @param {Array<any>} categories - Array of category objects
|
||||
*/
|
||||
groupScriptsByCategory(scripts, categories) {
|
||||
const categoryMap = new Map();
|
||||
categories.forEach(cat => categoryMap.set(cat.id, cat.name));
|
||||
|
||||
const grouped = new Map();
|
||||
|
||||
scripts.forEach(script => {
|
||||
const scriptCategories = script.categories || [0]; // Default to Miscellaneous (id: 0)
|
||||
scriptCategories.forEach((/** @type {number} */ catId) => {
|
||||
const categoryName = categoryMap.get(catId) || 'Miscellaneous';
|
||||
if (!grouped.has(categoryName)) {
|
||||
grouped.set(categoryName, []);
|
||||
}
|
||||
grouped.get(categoryName).push(script.name);
|
||||
});
|
||||
});
|
||||
|
||||
return grouped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notification about sync results
|
||||
* @param {Object} results - Sync results object
|
||||
*/
|
||||
async sendSyncNotification(results) {
|
||||
const settings = this.loadSettings();
|
||||
|
||||
if (!settings.notificationEnabled || !settings.appriseUrls?.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
const title = 'ProxmoxVE-Local - Auto-Sync Completed';
|
||||
let body = `Auto-sync completed successfully.\n\n`;
|
||||
|
||||
// Add JSON sync info
|
||||
// @ts-ignore - Dynamic property access
|
||||
if (results.jsonSync) {
|
||||
// @ts-ignore - Dynamic property access
|
||||
body += `JSON Files: ${results.jsonSync.syncedCount} synced, ${results.jsonSync.skippedCount} up-to-date\n`;
|
||||
// @ts-ignore - Dynamic property access
|
||||
if (results.jsonSync.errors?.length > 0) {
|
||||
// @ts-ignore - Dynamic property access
|
||||
body += `JSON Errors: ${results.jsonSync.errors.length}\n`;
|
||||
}
|
||||
body += '\n';
|
||||
}
|
||||
|
||||
// Load categories for grouping
|
||||
const categories = this.loadCategories();
|
||||
|
||||
// @ts-ignore - Dynamic property access
|
||||
if (results.newScripts?.length > 0) {
|
||||
// @ts-ignore - Dynamic property access
|
||||
body += `New scripts downloaded: ${results.newScripts.length}\n`;
|
||||
|
||||
// Group new scripts by category
|
||||
// @ts-ignore - Dynamic property access
|
||||
const newScriptsGrouped = this.groupScriptsByCategory(results.newScripts, categories);
|
||||
|
||||
// Sort categories by name for consistent ordering
|
||||
const sortedCategories = Array.from(newScriptsGrouped.keys()).sort();
|
||||
|
||||
sortedCategories.forEach(categoryName => {
|
||||
const scripts = newScriptsGrouped.get(categoryName);
|
||||
body += `\n**${categoryName}:**\n`;
|
||||
scripts.forEach((/** @type {string} */ scriptName) => {
|
||||
body += `• ${scriptName}\n`;
|
||||
});
|
||||
});
|
||||
body += '\n';
|
||||
}
|
||||
|
||||
// @ts-ignore - Dynamic property access
|
||||
if (results.updatedScripts?.length > 0) {
|
||||
// @ts-ignore - Dynamic property access
|
||||
body += `Scripts updated: ${results.updatedScripts.length}\n`;
|
||||
|
||||
// Group updated scripts by category
|
||||
// @ts-ignore - Dynamic property access
|
||||
const updatedScriptsGrouped = this.groupScriptsByCategory(results.updatedScripts, categories);
|
||||
|
||||
// Sort categories by name for consistent ordering
|
||||
const sortedCategories = Array.from(updatedScriptsGrouped.keys()).sort();
|
||||
|
||||
sortedCategories.forEach(categoryName => {
|
||||
const scripts = updatedScriptsGrouped.get(categoryName);
|
||||
body += `\n**${categoryName}:**\n`;
|
||||
scripts.forEach((/** @type {string} */ scriptName) => {
|
||||
body += `• ${scriptName}\n`;
|
||||
});
|
||||
});
|
||||
body += '\n';
|
||||
}
|
||||
|
||||
// @ts-ignore - Dynamic property access
|
||||
if (results.errors?.length > 0) {
|
||||
// @ts-ignore - Dynamic property access
|
||||
body += `Script errors encountered: ${results.errors.length}\n`;
|
||||
// @ts-ignore - Dynamic property access
|
||||
body += `• ${results.errors.slice(0, 5).join('\n• ')}\n`;
|
||||
// @ts-ignore - Dynamic property access
|
||||
if (results.errors.length > 5) {
|
||||
// @ts-ignore - Dynamic property access
|
||||
body += `• ... and ${results.errors.length - 5} more errors\n`;
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-ignore - Dynamic property access
|
||||
if (results.newScripts?.length === 0 && results.updatedScripts?.length === 0 && results.errors?.length === 0) {
|
||||
body += 'No script changes detected.';
|
||||
}
|
||||
|
||||
try {
|
||||
await appriseService.sendNotification(title, body, settings.appriseUrls);
|
||||
console.log('Sync notification sent successfully');
|
||||
} catch (error) {
|
||||
console.error('Failed to send sync notification:', error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test notification
|
||||
*/
|
||||
async testNotification() {
|
||||
const settings = this.loadSettings();
|
||||
|
||||
if (!settings.notificationEnabled || !settings.appriseUrls?.length) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'Notifications not enabled or no Apprise URLs configured'
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
await appriseService.sendNotification(
|
||||
'ProxmoxVE-Local - Test Notification',
|
||||
'This is a test notification from PVE Scripts Local auto-sync feature.',
|
||||
settings.appriseUrls
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'Test notification sent successfully'
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
success: false,
|
||||
message: `Failed to send test notification: ${error instanceof Error ? error.message : String(error)}`
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get auto-sync status
|
||||
*/
|
||||
getStatus() {
|
||||
return {
|
||||
isRunning: this.isRunning,
|
||||
hasCronJob: !!this.cronJob,
|
||||
lastSync: this.loadSettings().lastAutoSync
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,276 +0,0 @@
|
||||
import { writeFile, mkdir } from 'fs/promises';
|
||||
import { readFileSync, readdirSync, statSync, utimesSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { Buffer } from 'buffer';
|
||||
|
||||
export class GitHubJsonService {
|
||||
constructor() {
|
||||
this.baseUrl = null;
|
||||
this.repoUrl = null;
|
||||
this.branch = null;
|
||||
this.jsonFolder = null;
|
||||
this.localJsonDirectory = null;
|
||||
this.scriptCache = new Map();
|
||||
}
|
||||
|
||||
initializeConfig() {
|
||||
if (this.repoUrl === null) {
|
||||
// Get environment variables
|
||||
this.repoUrl = process.env.REPO_URL || "";
|
||||
this.branch = process.env.REPO_BRANCH || "main";
|
||||
this.jsonFolder = process.env.JSON_FOLDER || "scripts";
|
||||
this.localJsonDirectory = join(process.cwd(), 'scripts', 'json');
|
||||
|
||||
// Only validate GitHub URL if it's provided
|
||||
if (this.repoUrl) {
|
||||
// Extract owner and repo from the URL
|
||||
const urlMatch = /github\.com\/([^\/]+)\/([^\/]+)/.exec(this.repoUrl);
|
||||
if (!urlMatch) {
|
||||
throw new Error(`Invalid GitHub repository URL: ${this.repoUrl}`);
|
||||
}
|
||||
|
||||
const [, owner, repo] = urlMatch;
|
||||
this.baseUrl = `https://api.github.com/repos/${owner}/${repo}`;
|
||||
} else {
|
||||
// Set a dummy base URL if no REPO_URL is provided
|
||||
this.baseUrl = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fetchFromGitHub(endpoint) {
|
||||
this.initializeConfig();
|
||||
const response = await fetch(`${this.baseUrl}${endpoint}`, {
|
||||
headers: {
|
||||
'Accept': 'application/vnd.github.v3+json',
|
||||
'User-Agent': 'PVEScripts-Local/1.0',
|
||||
...(process.env.GITHUB_TOKEN && { 'Authorization': `token ${process.env.GITHUB_TOKEN}` })
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`GitHub API error: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async syncJsonFiles() {
|
||||
try {
|
||||
this.initializeConfig();
|
||||
|
||||
if (!this.baseUrl) {
|
||||
return {
|
||||
success: false,
|
||||
message: 'No GitHub repository configured'
|
||||
};
|
||||
}
|
||||
|
||||
console.log('Starting fast incremental JSON sync...');
|
||||
|
||||
// Ensure local directory exists
|
||||
await mkdir(this.localJsonDirectory, { recursive: true });
|
||||
|
||||
// Step 1: Get file list from GitHub (single API call)
|
||||
console.log('Fetching file list from GitHub...');
|
||||
const files = await this.fetchFromGitHub(`/contents/${this.jsonFolder}?ref=${this.branch}`);
|
||||
|
||||
if (!Array.isArray(files)) {
|
||||
throw new Error('Invalid response from GitHub API');
|
||||
}
|
||||
|
||||
const jsonFiles = files.filter(file => file.name.endsWith('.json'));
|
||||
console.log(`Found ${jsonFiles.length} JSON files in repository`);
|
||||
|
||||
// Step 2: Get local file list (fast local operation)
|
||||
const localFiles = new Map();
|
||||
try {
|
||||
console.log(`Looking for local files in: ${this.localJsonDirectory}`);
|
||||
const localFileList = readdirSync(this.localJsonDirectory);
|
||||
console.log(`Found ${localFileList.length} files in local directory`);
|
||||
for (const fileName of localFileList) {
|
||||
if (fileName.endsWith('.json')) {
|
||||
const filePath = join(this.localJsonDirectory, fileName);
|
||||
const stats = statSync(filePath);
|
||||
localFiles.set(fileName, {
|
||||
mtime: stats.mtime,
|
||||
size: stats.size
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('Error reading local directory:', error.message);
|
||||
console.log('Directory path:', this.localJsonDirectory);
|
||||
console.log('No local files found, will download all');
|
||||
}
|
||||
|
||||
console.log(`Found ${localFiles.size} local JSON files`);
|
||||
|
||||
// Step 3: Compare and identify files that need syncing
|
||||
const filesToSync = [];
|
||||
let skippedCount = 0;
|
||||
|
||||
for (const file of jsonFiles) {
|
||||
const localFile = localFiles.get(file.name);
|
||||
|
||||
if (!localFile) {
|
||||
// File doesn't exist locally
|
||||
filesToSync.push(file);
|
||||
console.log(`Missing: ${file.name}`);
|
||||
} else {
|
||||
// Compare modification times and sizes
|
||||
const localMtime = new Date(localFile.mtime);
|
||||
const remoteMtime = new Date(file.updated_at);
|
||||
const localSize = localFile.size;
|
||||
const remoteSize = file.size;
|
||||
|
||||
// Sync if remote is newer OR sizes are different (content changed)
|
||||
if (localMtime < remoteMtime || localSize !== remoteSize) {
|
||||
filesToSync.push(file);
|
||||
console.log(`Changed: ${file.name} (${localMtime.toISOString()} -> ${remoteMtime.toISOString()})`);
|
||||
} else {
|
||||
skippedCount++;
|
||||
console.log(`Up-to-date: ${file.name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Files to sync: ${filesToSync.length}, Up-to-date: ${skippedCount}`);
|
||||
|
||||
// Step 4: Download only the files that need syncing
|
||||
let syncedCount = 0;
|
||||
const errors = [];
|
||||
const syncedFiles = [];
|
||||
|
||||
// Process files in batches to avoid overwhelming the API
|
||||
const batchSize = 10;
|
||||
for (let i = 0; i < filesToSync.length; i += batchSize) {
|
||||
const batch = filesToSync.slice(i, i + batchSize);
|
||||
|
||||
// Process batch in parallel
|
||||
const promises = batch.map(async (file) => {
|
||||
try {
|
||||
const content = await this.fetchFromGitHub(`/contents/${file.path}?ref=${this.branch}`);
|
||||
|
||||
if (content.content) {
|
||||
// Decode base64 content
|
||||
const fileContent = Buffer.from(content.content, 'base64').toString('utf-8');
|
||||
|
||||
// Write to local file
|
||||
const localPath = join(this.localJsonDirectory, file.name);
|
||||
await writeFile(localPath, fileContent, 'utf-8');
|
||||
|
||||
// Update file modification time to match remote
|
||||
const remoteMtime = new Date(file.updated_at);
|
||||
utimesSync(localPath, remoteMtime, remoteMtime);
|
||||
|
||||
syncedCount++;
|
||||
syncedFiles.push(file.name);
|
||||
console.log(`Synced: ${file.name}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to sync ${file.name}:`, error.message);
|
||||
errors.push(`${file.name}: ${error.message}`);
|
||||
}
|
||||
});
|
||||
|
||||
await Promise.all(promises);
|
||||
|
||||
// Small delay between batches to be nice to the API
|
||||
if (i + batchSize < filesToSync.length) {
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`JSON sync completed. Synced ${syncedCount} files, skipped ${skippedCount} files.`);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `Successfully synced ${syncedCount} JSON files (${skippedCount} up-to-date)`,
|
||||
syncedCount,
|
||||
skippedCount,
|
||||
syncedFiles,
|
||||
errors
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.error('JSON sync failed:', error);
|
||||
return {
|
||||
success: false,
|
||||
message: error.message,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async getAllScripts() {
|
||||
try {
|
||||
this.initializeConfig();
|
||||
|
||||
if (!this.localJsonDirectory) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const scripts = [];
|
||||
|
||||
// Read all JSON files from local directory
|
||||
const files = readdirSync(this.localJsonDirectory);
|
||||
const jsonFiles = files.filter(file => file.endsWith('.json'));
|
||||
|
||||
for (const file of jsonFiles) {
|
||||
try {
|
||||
const filePath = join(this.localJsonDirectory, file);
|
||||
const content = readFileSync(filePath, 'utf-8');
|
||||
const script = JSON.parse(content);
|
||||
|
||||
if (script && typeof script === 'object') {
|
||||
scripts.push(script);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to parse ${file}:`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
return scripts;
|
||||
} catch (error) {
|
||||
console.error('Failed to get all scripts:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scripts only for specific JSON files that were synced
|
||||
*/
|
||||
async getScriptsForFiles(syncedFiles) {
|
||||
try {
|
||||
this.initializeConfig();
|
||||
|
||||
if (!this.localJsonDirectory || !syncedFiles || syncedFiles.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const scripts = [];
|
||||
|
||||
for (const fileName of syncedFiles) {
|
||||
try {
|
||||
const filePath = join(this.localJsonDirectory, fileName);
|
||||
const content = readFileSync(filePath, 'utf-8');
|
||||
const script = JSON.parse(content);
|
||||
|
||||
if (script && typeof script === 'object') {
|
||||
scripts.push(script);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to parse ${fileName}:`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
return scripts;
|
||||
} catch (error) {
|
||||
console.error('Failed to get scripts for synced files:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const githubJsonService = new GitHubJsonService();
|
||||
@@ -1,346 +0,0 @@
|
||||
import { writeFile, readFile, mkdir } from 'fs/promises';
|
||||
import { join } from 'path';
|
||||
|
||||
export class ScriptDownloaderService {
|
||||
constructor() {
|
||||
this.scriptsDirectory = null;
|
||||
}
|
||||
|
||||
initializeConfig() {
|
||||
if (this.scriptsDirectory === null) {
|
||||
this.scriptsDirectory = join(process.cwd(), 'scripts');
|
||||
}
|
||||
}
|
||||
|
||||
async ensureDirectoryExists(dirPath) {
|
||||
try {
|
||||
await mkdir(dirPath, { recursive: true });
|
||||
} catch (error) {
|
||||
if (error.code !== 'EEXIST') {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async downloadFileFromGitHub(filePath) {
|
||||
// This is a simplified version - in a real implementation,
|
||||
// you would fetch the file content from GitHub
|
||||
// For now, we'll return a placeholder
|
||||
return `#!/bin/bash
|
||||
# Downloaded script: ${filePath}
|
||||
# This is a placeholder - implement actual GitHub file download
|
||||
echo "Script downloaded: ${filePath}"
|
||||
`;
|
||||
}
|
||||
|
||||
modifyScriptContent(content) {
|
||||
// Modify script content for CT scripts if needed
|
||||
return content;
|
||||
}
|
||||
|
||||
async loadScript(script) {
|
||||
this.initializeConfig();
|
||||
try {
|
||||
const files = [];
|
||||
|
||||
// Ensure directories exist
|
||||
await this.ensureDirectoryExists(join(this.scriptsDirectory, 'ct'));
|
||||
await this.ensureDirectoryExists(join(this.scriptsDirectory, 'install'));
|
||||
await this.ensureDirectoryExists(join(this.scriptsDirectory, 'tools'));
|
||||
await this.ensureDirectoryExists(join(this.scriptsDirectory, 'vm'));
|
||||
|
||||
if (script.install_methods?.length) {
|
||||
for (const method of script.install_methods) {
|
||||
if (method.script) {
|
||||
const scriptPath = method.script;
|
||||
const fileName = scriptPath.split('/').pop();
|
||||
|
||||
if (fileName) {
|
||||
// Download from GitHub
|
||||
const content = await this.downloadFileFromGitHub(scriptPath);
|
||||
|
||||
// Determine target directory based on script path
|
||||
let targetDir;
|
||||
let finalTargetDir;
|
||||
let filePath;
|
||||
|
||||
if (scriptPath.startsWith('ct/')) {
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
// Modify the content for CT scripts
|
||||
const modifiedContent = this.modifyScriptContent(content);
|
||||
filePath = join(this.scriptsDirectory, targetDir, fileName);
|
||||
await writeFile(filePath, modifiedContent, 'utf-8');
|
||||
} else if (scriptPath.startsWith('tools/')) {
|
||||
targetDir = 'tools';
|
||||
// Preserve subdirectory structure for tools scripts
|
||||
const subPath = scriptPath.replace('tools/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
// Ensure the subdirectory exists
|
||||
await this.ensureDirectoryExists(join(this.scriptsDirectory, finalTargetDir));
|
||||
filePath = join(this.scriptsDirectory, finalTargetDir, fileName);
|
||||
await writeFile(filePath, content, 'utf-8');
|
||||
} else if (scriptPath.startsWith('vm/')) {
|
||||
targetDir = 'vm';
|
||||
// Preserve subdirectory structure for VM scripts
|
||||
const subPath = scriptPath.replace('vm/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
// Ensure the subdirectory exists
|
||||
await this.ensureDirectoryExists(join(this.scriptsDirectory, finalTargetDir));
|
||||
filePath = join(this.scriptsDirectory, finalTargetDir, fileName);
|
||||
await writeFile(filePath, content, 'utf-8');
|
||||
} else if (scriptPath.startsWith('vw/')) {
|
||||
targetDir = 'vw';
|
||||
// Preserve subdirectory structure for VW scripts
|
||||
const subPath = scriptPath.replace('vw/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
// Ensure the subdirectory exists
|
||||
await this.ensureDirectoryExists(join(this.scriptsDirectory, finalTargetDir));
|
||||
filePath = join(this.scriptsDirectory, finalTargetDir, fileName);
|
||||
await writeFile(filePath, content, 'utf-8');
|
||||
} else {
|
||||
// Handle other script types (fallback to ct directory)
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
const modifiedContent = this.modifyScriptContent(content);
|
||||
filePath = join(this.scriptsDirectory, targetDir, fileName);
|
||||
await writeFile(filePath, modifiedContent, 'utf-8');
|
||||
}
|
||||
|
||||
files.push(`${finalTargetDir}/${fileName}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only download install script for CT scripts
|
||||
const hasCtScript = script.install_methods?.some(method => method.script?.startsWith('ct/'));
|
||||
if (hasCtScript) {
|
||||
const installScriptName = `${script.slug}-install.sh`;
|
||||
try {
|
||||
const installContent = await this.downloadFileFromGitHub(`install/${installScriptName}`);
|
||||
const localInstallPath = join(this.scriptsDirectory, 'install', installScriptName);
|
||||
await writeFile(localInstallPath, installContent, 'utf-8');
|
||||
files.push(`install/${installScriptName}`);
|
||||
} catch {
|
||||
// Install script might not exist, that's okay
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `Successfully loaded ${files.length} script(s) for ${script.name}`,
|
||||
files
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error loading script:', error);
|
||||
return {
|
||||
success: false,
|
||||
message: error instanceof Error ? error.message : 'Failed to load script',
|
||||
files: []
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-download new scripts that haven't been downloaded yet
|
||||
*/
|
||||
async autoDownloadNewScripts(allScripts) {
|
||||
this.initializeConfig();
|
||||
const downloaded = [];
|
||||
const errors = [];
|
||||
|
||||
for (const script of allScripts) {
|
||||
try {
|
||||
// Check if script is already downloaded
|
||||
const isDownloaded = await this.isScriptDownloaded(script);
|
||||
|
||||
if (!isDownloaded) {
|
||||
const result = await this.loadScript(script);
|
||||
if (result.success) {
|
||||
downloaded.push(script); // Return full script object instead of just name
|
||||
console.log(`Auto-downloaded new script: ${script.name || script.slug}`);
|
||||
} else {
|
||||
errors.push(`${script.name || script.slug}: ${result.message}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMsg = `${script.name || script.slug}: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
||||
errors.push(errorMsg);
|
||||
console.error(`Failed to auto-download script ${script.slug}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
return { downloaded, errors };
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-update existing scripts to newer versions
|
||||
*/
|
||||
async autoUpdateExistingScripts(allScripts) {
|
||||
this.initializeConfig();
|
||||
const updated = [];
|
||||
const errors = [];
|
||||
|
||||
for (const script of allScripts) {
|
||||
try {
|
||||
// Check if script is downloaded
|
||||
const isDownloaded = await this.isScriptDownloaded(script);
|
||||
|
||||
if (isDownloaded) {
|
||||
// Check if update is needed by comparing content
|
||||
const needsUpdate = await this.scriptNeedsUpdate(script);
|
||||
|
||||
if (needsUpdate) {
|
||||
const result = await this.loadScript(script);
|
||||
if (result.success) {
|
||||
updated.push(script); // Return full script object instead of just name
|
||||
console.log(`Auto-updated script: ${script.name || script.slug}`);
|
||||
} else {
|
||||
errors.push(`${script.name || script.slug}: ${result.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMsg = `${script.name || script.slug}: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
||||
errors.push(errorMsg);
|
||||
console.error(`Failed to auto-update script ${script.slug}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
return { updated, errors };
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a script is already downloaded
|
||||
*/
|
||||
async isScriptDownloaded(script) {
|
||||
if (!script.install_methods?.length) return false;
|
||||
|
||||
// Check if ALL script files are downloaded
|
||||
for (const method of script.install_methods) {
|
||||
if (method.script) {
|
||||
const scriptPath = method.script;
|
||||
const fileName = scriptPath.split('/').pop();
|
||||
|
||||
if (fileName) {
|
||||
// Determine target directory based on script path
|
||||
let targetDir;
|
||||
let finalTargetDir;
|
||||
let filePath;
|
||||
|
||||
if (scriptPath.startsWith('ct/')) {
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
filePath = join(this.scriptsDirectory, targetDir, fileName);
|
||||
} else if (scriptPath.startsWith('tools/')) {
|
||||
targetDir = 'tools';
|
||||
const subPath = scriptPath.replace('tools/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory, finalTargetDir, fileName);
|
||||
} else if (scriptPath.startsWith('vm/')) {
|
||||
targetDir = 'vm';
|
||||
const subPath = scriptPath.replace('vm/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory, finalTargetDir, fileName);
|
||||
} else if (scriptPath.startsWith('vw/')) {
|
||||
targetDir = 'vw';
|
||||
const subPath = scriptPath.replace('vw/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory, finalTargetDir, fileName);
|
||||
} else {
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
filePath = join(this.scriptsDirectory, targetDir, fileName);
|
||||
}
|
||||
|
||||
try {
|
||||
await readFile(filePath, 'utf8');
|
||||
// File exists, continue checking other methods
|
||||
} catch {
|
||||
// File doesn't exist, script is not fully downloaded
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All files exist, script is downloaded
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a script needs updating by comparing local and remote content
|
||||
*/
|
||||
async scriptNeedsUpdate(script) {
|
||||
if (!script.install_methods?.length) return false;
|
||||
|
||||
for (const method of script.install_methods) {
|
||||
if (method.script) {
|
||||
const scriptPath = method.script;
|
||||
const fileName = scriptPath.split('/').pop();
|
||||
|
||||
if (fileName) {
|
||||
// Determine target directory based on script path
|
||||
let targetDir;
|
||||
let finalTargetDir;
|
||||
let filePath;
|
||||
|
||||
if (scriptPath.startsWith('ct/')) {
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
filePath = join(this.scriptsDirectory, targetDir, fileName);
|
||||
} else if (scriptPath.startsWith('tools/')) {
|
||||
targetDir = 'tools';
|
||||
const subPath = scriptPath.replace('tools/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory, finalTargetDir, fileName);
|
||||
} else if (scriptPath.startsWith('vm/')) {
|
||||
targetDir = 'vm';
|
||||
const subPath = scriptPath.replace('vm/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory, finalTargetDir, fileName);
|
||||
} else if (scriptPath.startsWith('vw/')) {
|
||||
targetDir = 'vw';
|
||||
const subPath = scriptPath.replace('vw/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory, finalTargetDir, fileName);
|
||||
} else {
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
filePath = join(this.scriptsDirectory, targetDir, fileName);
|
||||
}
|
||||
|
||||
try {
|
||||
// Read local content
|
||||
const localContent = await readFile(filePath, 'utf8');
|
||||
|
||||
// Download remote content
|
||||
const remoteContent = await this.downloadFileFromGitHub(scriptPath);
|
||||
|
||||
// Compare content (simple string comparison for now)
|
||||
// In a more sophisticated implementation, you might want to compare
|
||||
// file modification times or use content hashing
|
||||
return localContent !== remoteContent;
|
||||
} catch {
|
||||
// If we can't read local or download remote, assume update needed
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export const scriptDownloaderService = new ScriptDownloaderService();
|
||||
@@ -167,203 +167,6 @@ export class ScriptDownloaderService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-download new scripts that haven't been downloaded yet
|
||||
*/
|
||||
async autoDownloadNewScripts(allScripts: Script[]): Promise<{ downloaded: string[]; errors: string[] }> {
|
||||
this.initializeConfig();
|
||||
const downloaded: string[] = [];
|
||||
const errors: string[] = [];
|
||||
|
||||
for (const script of allScripts) {
|
||||
try {
|
||||
// Check if script is already downloaded
|
||||
const isDownloaded = await this.isScriptDownloaded(script);
|
||||
|
||||
if (!isDownloaded) {
|
||||
const result = await this.loadScript(script);
|
||||
if (result.success) {
|
||||
downloaded.push(script.name || script.slug);
|
||||
console.log(`Auto-downloaded new script: ${script.name || script.slug}`);
|
||||
} else {
|
||||
errors.push(`${script.name || script.slug}: ${result.message}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMsg = `${script.name || script.slug}: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
||||
errors.push(errorMsg);
|
||||
console.error(`Failed to auto-download script ${script.slug}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
return { downloaded, errors };
|
||||
}
|
||||
|
||||
/**
|
||||
* Auto-update existing scripts to newer versions
|
||||
*/
|
||||
async autoUpdateExistingScripts(allScripts: Script[]): Promise<{ updated: string[]; errors: string[] }> {
|
||||
this.initializeConfig();
|
||||
const updated: string[] = [];
|
||||
const errors: string[] = [];
|
||||
|
||||
for (const script of allScripts) {
|
||||
try {
|
||||
// Check if script is downloaded
|
||||
const isDownloaded = await this.isScriptDownloaded(script);
|
||||
|
||||
if (isDownloaded) {
|
||||
// Check if update is needed by comparing content
|
||||
const needsUpdate = await this.scriptNeedsUpdate(script);
|
||||
|
||||
if (needsUpdate) {
|
||||
const result = await this.loadScript(script);
|
||||
if (result.success) {
|
||||
updated.push(script.name || script.slug);
|
||||
console.log(`Auto-updated script: ${script.name || script.slug}`);
|
||||
} else {
|
||||
errors.push(`${script.name || script.slug}: ${result.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
const errorMsg = `${script.name || script.slug}: ${error instanceof Error ? error.message : 'Unknown error'}`;
|
||||
errors.push(errorMsg);
|
||||
console.error(`Failed to auto-update script ${script.slug}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
return { updated, errors };
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a script is already downloaded
|
||||
*/
|
||||
async isScriptDownloaded(script: Script): Promise<boolean> {
|
||||
if (!script.install_methods?.length) return false;
|
||||
|
||||
// Check if ALL script files are downloaded
|
||||
for (const method of script.install_methods) {
|
||||
if (method.script) {
|
||||
const scriptPath = method.script;
|
||||
const fileName = scriptPath.split('/').pop();
|
||||
|
||||
if (fileName) {
|
||||
// Determine target directory based on script path
|
||||
let targetDir: string;
|
||||
let finalTargetDir: string;
|
||||
let filePath: string;
|
||||
|
||||
if (scriptPath.startsWith('ct/')) {
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
filePath = join(this.scriptsDirectory!, targetDir, fileName);
|
||||
} else if (scriptPath.startsWith('tools/')) {
|
||||
targetDir = 'tools';
|
||||
const subPath = scriptPath.replace('tools/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory!, finalTargetDir, fileName);
|
||||
} else if (scriptPath.startsWith('vm/')) {
|
||||
targetDir = 'vm';
|
||||
const subPath = scriptPath.replace('vm/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory!, finalTargetDir, fileName);
|
||||
} else if (scriptPath.startsWith('vw/')) {
|
||||
targetDir = 'vw';
|
||||
const subPath = scriptPath.replace('vw/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory!, finalTargetDir, fileName);
|
||||
} else {
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
filePath = join(this.scriptsDirectory!, targetDir, fileName);
|
||||
}
|
||||
|
||||
try {
|
||||
await readFile(filePath, 'utf8');
|
||||
// File exists, continue checking other methods
|
||||
} catch {
|
||||
// File doesn't exist, script is not fully downloaded
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All files exist, script is downloaded
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a script needs updating by comparing local and remote content
|
||||
*/
|
||||
private async scriptNeedsUpdate(script: Script): Promise<boolean> {
|
||||
if (!script.install_methods?.length) return false;
|
||||
|
||||
for (const method of script.install_methods) {
|
||||
if (method.script) {
|
||||
const scriptPath = method.script;
|
||||
const fileName = scriptPath.split('/').pop();
|
||||
|
||||
if (fileName) {
|
||||
// Determine target directory based on script path
|
||||
let targetDir: string;
|
||||
let finalTargetDir: string;
|
||||
let filePath: string;
|
||||
|
||||
if (scriptPath.startsWith('ct/')) {
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
filePath = join(this.scriptsDirectory!, targetDir, fileName);
|
||||
} else if (scriptPath.startsWith('tools/')) {
|
||||
targetDir = 'tools';
|
||||
const subPath = scriptPath.replace('tools/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory!, finalTargetDir, fileName);
|
||||
} else if (scriptPath.startsWith('vm/')) {
|
||||
targetDir = 'vm';
|
||||
const subPath = scriptPath.replace('vm/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory!, finalTargetDir, fileName);
|
||||
} else if (scriptPath.startsWith('vw/')) {
|
||||
targetDir = 'vw';
|
||||
const subPath = scriptPath.replace('vw/', '');
|
||||
const subDir = subPath.includes('/') ? subPath.substring(0, subPath.lastIndexOf('/')) : '';
|
||||
finalTargetDir = subDir ? join(targetDir, subDir) : targetDir;
|
||||
filePath = join(this.scriptsDirectory!, finalTargetDir, fileName);
|
||||
} else {
|
||||
targetDir = 'ct';
|
||||
finalTargetDir = targetDir;
|
||||
filePath = join(this.scriptsDirectory!, targetDir, fileName);
|
||||
}
|
||||
|
||||
try {
|
||||
// Read local content
|
||||
const localContent = await readFile(filePath, 'utf8');
|
||||
|
||||
// Download remote content
|
||||
const remoteContent = await this.downloadFileFromGitHub(scriptPath);
|
||||
|
||||
// Compare content (simple string comparison for now)
|
||||
// In a more sophisticated implementation, you might want to compare
|
||||
// file modification times or use content hashing
|
||||
return localContent !== remoteContent;
|
||||
} catch {
|
||||
// If we can't read local or download remote, assume update needed
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
async checkScriptExists(script: Script): Promise<{ ctExists: boolean; installExists: boolean; files: string[] }> {
|
||||
this.initializeConfig();
|
||||
const files: string[] = [];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
#21.10.2025 - @michelroegl-brunner
|
||||
#21.10.2025
|
||||
# Enhanced update script for ProxmoxVE-Local
|
||||
# Fetches latest release from GitHub and backs up data directory
|
||||
|
||||
@@ -551,6 +551,7 @@ update_files() {
|
||||
"*.backup"
|
||||
"*.bak"
|
||||
"scripts"
|
||||
"prisma/migrations"
|
||||
)
|
||||
|
||||
# Find the actual source directory (strip the top-level directory)
|
||||
@@ -621,7 +622,6 @@ update_files() {
|
||||
log_success "Application files updated successfully ($files_copied files)"
|
||||
}
|
||||
|
||||
|
||||
# Install dependencies and build
|
||||
install_and_build() {
|
||||
log "Installing dependencies..."
|
||||
@@ -927,6 +927,7 @@ main() {
|
||||
# Restore .env and data directory before building
|
||||
restore_backup_files
|
||||
|
||||
|
||||
# Verify database was restored correctly
|
||||
if ! verify_database_restored; then
|
||||
log_error "Database verification failed, rolling back..."
|
||||
|
||||
Reference in New Issue
Block a user