| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2ba75e3 commit 03d602a
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,5 @@ dist-ssr | |||
| 26 | 26 | release | |
| 27 | 27 | ||
| 28 | 28 | public/laravel | |
| 29 | - public/client-*.phar | ||
| 30 | 29 | ||
| 31 | 30 | .env | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ | |||
| 11 | 11 | "main": "dist/main.js", | |
| 12 | 12 | "scripts": { | |
| 13 | 13 | "dev": "vite", | |
| 14 | + "update-clients": "node ./scripts/update-clients.js", | ||
| 14 | 15 | "build": "vue-tsc && vite build", | |
| 15 | 16 | "build-mac": "npm run build && electron-builder --publish always --mac --universal", | |
| 16 | 17 | "preview": "vite preview", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,47 @@ | |||
| 1 | + import path from 'path' | ||
| 2 | + import fs from 'fs' | ||
| 3 | + import fetch from 'node-fetch' | ||
| 4 | + import * as glob from 'glob' | ||
| 5 | + import { fileURLToPath } from 'url' | ||
| 6 | + | ||
| 7 | + const __filename = fileURLToPath(import.meta.url) | ||
| 8 | + const __dirname = path.dirname(__filename) | ||
| 9 | + | ||
| 10 | + function cleanup() { | ||
| 11 | + const files = glob.sync(path.join(__dirname, '../public', 'client-*.phar')) | ||
| 12 | + files.forEach(file => { | ||
| 13 | + fs.unlinkSync(file) | ||
| 14 | + }) | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + async function downloadFile(url, output) { | ||
| 18 | + const response = await fetch(url) | ||
| 19 | + if (!response.ok) throw new Error(`Failed to fetch ${url}`) | ||
| 20 | + | ||
| 21 | + const destPath = path.resolve(__dirname, '..', output) | ||
| 22 | + fs.mkdirSync(path.dirname(destPath), { recursive: true }) | ||
| 23 | + | ||
| 24 | + const fileStream = fs.createWriteStream(destPath) | ||
| 25 | + response.body.pipe(fileStream) | ||
| 26 | + | ||
| 27 | + return new Promise((resolve, reject) => { | ||
| 28 | + fileStream.on('finish', resolve) | ||
| 29 | + fileStream.on('error', reject) | ||
| 30 | + }) | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + cleanup() | ||
| 34 | + | ||
| 35 | + fetch('https://api.github.com/repos/tweakphp/client/releases/latest') | ||
| 36 | + .then(response => response.json()) | ||
| 37 | + .then(data => { | ||
| 38 | + data.assets.forEach(async asset => { | ||
| 39 | + const url = asset.browser_download_url | ||
| 40 | + const filePath = path.join(__dirname, '../public', asset.name) | ||
| 41 | + await downloadFile(url, filePath) | ||
| 42 | + }) | ||
| 43 | + console.log('Downloaded all client files.') | ||
| 44 | + }) | ||
| 45 | + .catch(err => { | ||
| 46 | + console.error('Error fetching release data:', err.message) | ||
| 47 | + }) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments