[CI > Win] Rewrite downloading in Node

pull/52/head
Oj 2 years ago
parent 1117f6ae4b
commit 7dacb23daf

@ -98,9 +98,8 @@ jobs:
- name: Setup Client
run: |
# Download latest client from updater v2 and extract (manifest -> brotli -> tar)
wget "$(curl 'https://discord.com/api/updates/distributions/app/manifests/latest?channel=canary&platform=win&arch=x86' | python -c 'import json,sys;print(json.load(sys.stdin)["full"]["url"])')"
node -e "fs.writeFileSync('full.tar', zlib.brotliDecompressSync(fs.readFileSync('full.distro')))"
tar xf full.tar
node scripts/downloadWin.js
tar xf client.tar
# Install OpenAsar build and setup environment
sed -i "s/^\/\/ <TEST_FLAG_WINDOWS>.*$/if \(name == 'discord_rpc'\) { console.log\('ABRA'\); process.exit\(\); }/" app.asar

@ -0,0 +1,35 @@
const { get } = require('https');
const zlib = require('zlib');
const fs = require('fs');
console.log('getting manifest...');
get('https://discord.com/api/updates/distributions/app/manifests/latest?channel=canary&platform=win&arch=x86', async (res) => {
let body = '';
res.on('data', (chunk) => {
body += chunk.toString();
});
await new Promise((resolve) => res.on('end', resolve)); // Wait to read full body
const manifest = JSON.parse(body);
const downloadUrl = manifest.full.url;
console.log('downloading full.distro...');
get(downloadUrl, async (res) => {
let body = [];
res.on('data', (chunk) => {
body.push(chunk);
});
await new Promise((resolve) => res.on('end', resolve)); // Wait to read full body
console.log('decompressing...');
body = Buffer.concat(data);
body = zlib.brotliDecompressSync(body);
fs.writeFileSync('client.tar', body);
});
});
Loading…
Cancel
Save